Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 800 posts 2039 karma points
    1 week ago
    Claushingebjerg
    0

    Rendering standard properties in 8

    How do we render standard properties in 8. The built in

    @Model.Value("pageName")
    

    Doesnt work - it renders nothing...

  • Sebastiaan Janssen 4805 posts 13980 karma points MVP admin hq
    1 week ago
    Sebastiaan Janssen
    0

    Try @Umbraco.Field("pageName") instead.

    You can use the insert button in the template editor too:

    enter image description here

  • Bjarne Fyrstenborg 1117 posts 3015 karma points MVP 2x c-trib
    1 week ago
    Bjarne Fyrstenborg
    100

    @Sebastiaan I think .Field() has been removed in v8 on UmbracoHelper so we don't have these different methods to extract property values.

    So it should just be the following, which inserting a field value also output.

    @Model.Value("property")

    @Claus is pageName a custom property? The node name can be accessed via Model.Name.

    Also ensure the page inherits from Umbraco.Web.Mvc.UmbracoViewPage.

    /Bjarne

  • Claushingebjerg 800 posts 2039 karma points
    1 week ago
    Claushingebjerg
    0

    Ok just to be clear - i used the built in "Insert value" button. it inserts

    @Model.Value("pageName")
    

    wich returns nothing - The same goes for the others like @Model.Value("createDate"), @Model.Value("pageID") and so on.

    Bjarne is right. @Umbraco.Field("pageName") doesnt work at all anymore, it throws errors.

    @Model.Name works, thanks Bjarne.

    So to sum it up, the built in "inset value" is broken when inserting standard system values.

  • Sebastiaan Janssen 4805 posts 13980 karma points MVP admin hq
    1 week ago
    Sebastiaan Janssen
    0

    Ah yeah, looks like this is being updated for the next version of 8 already, sorry to mislead you ;-)

  • Bjarne Fyrstenborg 1117 posts 3015 karma points MVP 2x c-trib
    1 week ago
    Bjarne Fyrstenborg
    0

    I see, you can however access these properties using the properties on IPublishedContent model, e.g.

    @Model.Id (pageID)`

    @Model.Name (pageName)

    @Model.CreateDate (createDate)

  • MuirisOG 356 posts 1173 karma points
    1 week ago
    MuirisOG
    0

    ... and how do you output the different language versions?

    Say your main language is English and you were on the Welsh version of the page, how do you output the Welsh page title?

    (I hope you don't mind me hijacking your question, Claushingebjerg).

  • Claushingebjerg 800 posts 2039 karma points
    1 week ago
    Claushingebjerg
    1

    I havent tried language variants yet, but according to a question i asked on the U8 webinar it works automatically by just using @Model.Name - The language variant system takes care of it out of the box.

    I could be wrong...

  • MuirisOG 356 posts 1173 karma points
    1 week ago
    MuirisOG
    0

    Many thanks...

    I think this should answer my question.

    https://our.umbraco.com/Documentation/Getting-Started/Design/Rendering-Content/

    Thanks

    Muiris

Please Sign in or register to post replies

Write your reply to:

Draft