Copied to clipboard

Flag this post as spam?

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


  • Bryna 73 posts 259 karma points
    Mar 27, 2019 @ 21:31
    Bryna
    0

    I have a document type which I have created and it is composed with another document type. I am able to display the page name as follows:

    @Model.Name
    

    I have tried using the following which I think is equivalent, but nothing is pulled back:

    @Model.Value("pageName")
    

    I have to utilize the second method to utilize the culture parameter for translation. Am I missing something really obvious? The Value method works for the custom properties that I have made on my document type, but I cannot access the page name that way for some reason(versions 8.0 and 8.0.1)

  • AddWeb Solution Pvt. Ltd 109 posts 360 karma points
    Mar 28, 2019 @ 06:00
    AddWeb Solution Pvt. Ltd
    0

    Please use below code its work fine for you.

    @foreach (var (culture, infos) in intlHomePage.Cultures)
    {
        <a href="@intlHomePage.GetUrl(culture)">
            @intlHomePage.Value("title", culture)
       </a>
    }
    

    Edit: Where intlHomePage would be the Models Builder class name of your current document type.

    Reference link

  • Bryna 73 posts 259 karma points
    Mar 29, 2019 @ 14:15
    Bryna
    0

    That doesn't return anything. It DOES return something for other properties. I tried using both title and pageTitle[because that is what the Umbraco backoffice UI fills in ]. I have noticed that it will not return Name, Url, or writerName either. Model.Url, Model.Name, and Model.writerName do work.

    Does this mean that Model.FieldName != Model.Value("filedname") with respect to the inherited properties[Ones from PublishedContentWrapped]?

  • Bryna 73 posts 259 karma points
    Apr 05, 2019 @ 15:38
    Bryna
    0

    For anyone who is having a similar problem, this is an answer that solves the issue, although I would still like to know why the more intuitive Model.Value("fieldname", culture: "de") doesn't work.

    @Model.GetCulture("de").Name  
    
  • Stephen 767 posts 2273 karma points c-trib
    Apr 06, 2019 @ 16:54
    Stephen
    100

    The "name" of a document is not a property (as in, a user-level property) of that document, hence Value() does not return it. Therefore, the proper way to get the name in another culture is, indeed content.GetCulture("de").Name.

    That being said, it's clumsy, and although I don't think we can get Value() to return it (because, what property alias would we use?), it annoys me that we don't have a simple content.GetName("de") overload.

    Adding this to my list!

  • Bryna 73 posts 259 karma points
    Apr 08, 2019 @ 20:19
    Bryna
    0

    Thank you Stephen. I'm going to mark you as having the answer because I think you addressed the more accurate underlying problem that this is unique to the Name of the page.

    I did manage to get other user level properties to work just fine, albeit with some rather nasty side effects, but those are more design related and not Umbraco:).

  • Tristan Thompson 3 posts 73 karma points c-trib
    Jan 19, 2021 @ 11:07
    Tristan Thompson
    0

    For anyone else who comes here (including my future self!), in newer versions of v8 there's a new extension method to extract the name property:

    content.Name("de")

Please Sign in or register to post replies

Write your reply to:

Draft