Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tara Pattenden 44 posts 205 karma points
    Sep 02, 2020 @ 01:00
    Tara Pattenden
    0

    404 errors when inserting any value

    Hi I am a complete noob at umbraco but have a lot of programming experience. Working on a theme i was originally told was in wordpress but now I am in the job it's umbraco and i'm trying to learn on the fly

    I am working with a website that is already installed. I am trying to make a new template. I created a doc type, and a template and a content item using the doc type.

    The issue I am having is as soon as i insert any of the values from the doc type then i get the following error.

    No umbraco document matches the url '/error.aspx?aspxerrorpath=/2268.aspx'.

    To insert the values I am using the drop down menu at the top of the template page.

    if it's just static content in the page, everything shows up

    Is there somewhere else i need to link up the content. Or is there an issue with aspx - I've not worked with aspx before. I'm hoping there's an obvious step that I don't know about.

    This is the code in the current page - this does not work

    @{
        Layout = null;
    }
    
    
    <section class="grid-container py24 md:py48">
        <div class="rte">
            @Umbraco.Field("tickertape")
        </div>
    
    </section>
    

    however this does work

    @{
        Layout = null;
    }
    
    
    <section class="grid-container py24 md:py48">
        <div class="rte">
            @Umbraco.Field("tickertape")
        </div>
    
    </section>
    

    Thanks in advance

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Sep 02, 2020 @ 07:41
    Steve Morgan
    0

    Did you accidentally paste the same code snippet or is that the query you have?!?

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Sep 02, 2020 @ 07:44
    Steve Morgan
    0

    One small thing - I wouldn't have thought ":" is a valid character in a css class name. But that wouldn't break Razor.

    Usually people's confusion with Razor is when and when not to use a '@'.

    If you're doing anything more complicated than Umbraco.Field (for example adding a ToString() then ensure you wrap it in brackets.

    @(Umbraco.Field("tickertape").ToString())

  • Tara Pattenden 44 posts 205 karma points
    Sep 04, 2020 @ 23:28
    Tara Pattenden
    0

    Hi thanks so much for your help. The issue I was having was actually due to the way the site I'm working on is set up. I needed the site to have a live switch on to avoid errors I have now been given a staging server which works. I did copy the same code as well. thanks for the tip about adding a ToString() It's useful!! I am definitely unsure when to use the @ It seems that my side is using page views and the .model syntax. I am very confused about when to use @umbraco.Field or @model. I've watched the umbraco.tv docs but there's not much for beginners. What i would really love to know is what a model is and how it is different from a doc type etc. I can only find advanced articles from searching. Would you have any tips?

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Sep 05, 2020 @ 15:10
    Steve Morgan
    100

    Hi, I'll try to write something clear whilst being mostly, technically correct (though I will blur the lines a bit for simiplicity).

    Model is what ever is being passed into the view / partial. It's probably the content node of the page you're on with access to all the properties on the doc type.

    You've cut the first couple of lines from your code example at the start - if you paste that I can be more exact. And also confirm you're on v7 not v8?!

    You've heard of MVC - Model, View, Controller. Model is your doc type (+ Umbraco extras and helpers), the view is your template and the controller (unless you override it) can be thought of as Umbraco which handles the page request and rendering the correct template with the model (content data).

    The Model can basically either be of a generic type IPublishedContent (which is something that you can use for any content node regardless of doc type) or a more specific, strongly typed, model - where your doc type properties are specific to the doc type and easier to access. It depends what's passed in and how the Umbraco installation is configured - look up Models builder when you're ready!

    You'll see a lot of examples online - the two easiest are Model.Content.GetPropertyValue which in razor would be @(Model.Content.GetPropertyValue

    This will get, as a string, the data in the doc type property with the alias in the quotes. The type is set in the < > brackets.

    If it's strongly typed you'd be able to do @Model.Content.DocTypePropertyAlias no need to specify the type because it's strongly typed in the model.

    The first example will always work and might be easiest to get you started... Umbraco.Field is useful for the tutorials but it's better to move to these IMHO.

    I know it's confusing to start... but it sounds like you're close!

  • Tara Pattenden 44 posts 205 karma points
    Sep 06, 2020 @ 03:58
    Tara Pattenden
    0

    Thanks so much! This really helped. I'm managing to make things work and slowly understanding as I go - I think. The site I am working on is in V7 they are using the models builder with liveappdata. There also seems to be some models they have written themselves (not existing as doc types in the back office)

    The main problem I am having is I can't seem to get a lot of the model properties to display. but I will make new posts now with specific issues. Thanks heaps!!

Please Sign in or register to post replies

Write your reply to:

Draft