Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 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 5060 posts 15522 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 1285 posts 4039 karma points MVP 8x c-trib
    Mar 14, 2019 @ 12:22
    Bjarne Fyrstenborg
    101

    @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 939 posts 2574 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 5060 posts 15522 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 1285 posts 4039 karma points MVP 8x c-trib
    Mar 14, 2019 @ 12:47
    Bjarne Fyrstenborg
    2

    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 382 posts 1284 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 939 posts 2574 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 382 posts 1284 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 939 posts 2574 karma points
    Apr 03, 2019 @ 11:53
    Claushingebjerg
    0

    This was not fixed in 8.01...

  • MuirisOG 382 posts 1284 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

  • LeaTark 22 posts 123 karma points
    Oct 10, 2019 @ 08:52
    LeaTark
    0

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

    The type of the return value has changed.

    Where we'd do this in v7

    @Model.Content.GetPropertyValue<string>("property", "").Split(',')

    It's now this in v8

    @Model.Content.Value<string[]>("property")

  • Walters Muller 4 posts 74 karma points
    Apr 30, 2020 @ 12:23
    Walters Muller
    0

    In Umbraco 8 I think it is a little confusing, the IntelliSense no longer display conentItem.Value<t> just conentItem.Value.

    Just to answer your question, it would simply be IPublishedContent.Value and yes the optional IPublishedContent.Value<T> also works. IPublishedContent being your content item.

    Now another thing I do find confusing is the optionlal ValueFor or ValueFor<T>, what is the difference? Could someone perhaps clear that up for us.

Please Sign in or register to post replies

Write your reply to:

Draft