Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 828 posts 2142 karma points
    Mar 14, 2019 @ 11:25
    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 4833 posts 14217 karma points MVP admin hq
    Mar 14, 2019 @ 12:10
    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 1135 posts 3217 karma points MVP 3x c-trib
    Mar 14, 2019 @ 12:22
    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 828 posts 2142 karma points
    Mar 14, 2019 @ 12:38
    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 4833 posts 14217 karma points MVP admin hq
    Mar 14, 2019 @ 12:42
    Sebastiaan Janssen
    0

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

  • Bjarne Fyrstenborg 1135 posts 3217 karma points MVP 3x c-trib
    Mar 14, 2019 @ 12:47
    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 366 posts 1224 karma points
    Mar 14, 2019 @ 13:29
    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 828 posts 2142 karma points
    Mar 14, 2019 @ 13:34
    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 366 posts 1224 karma points
    Mar 14, 2019 @ 13:41
    MuirisOG
    0

    Many thanks...

    I think this should answer my question.

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

    Thanks

    Muiris

  • Claushingebjerg 828 posts 2142 karma points
    Apr 03, 2019 @ 11:53
    Claushingebjerg
    0

    This was not fixed in 8.01...

  • MuirisOG 366 posts 1224 karma points
    Apr 03, 2019 @ 12:03
    MuirisOG
    0

    I've found these work in a PartialViewMacroPage

    For a custom property, try

    @Model.Content.Value("pageTitle")
    @Model.Content.Value<string>("pageTitle")
    

    ... and for core doctype properties, try

    @Model.Content.Id
    @Model.Content.Parent
    @Model.Content.TemplateId
    @Model.Content.SortOrder
    @Model.Content.Name
    @Model.Content.Url
    @Model.Content.WriterName
    @Model.Content.CreatorName
    @Model.Content.WriterId
    @Model.Content.Path
    @Model.Content.CreateDate
    @Model.Content.Level
    @Model.Content.ContentType
    @Model.Content.Properties
    

    ... and for CheckboxList, you can assign a variable with the following value.

    @Model.Content.GetProperty("myCategoryList").GetSourceValue()
    

    However, I got really stuck trying to get PreValues in the Partial View.

    Thanks

    Muiris

Please Sign in or register to post replies

Write your reply to:

Draft