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)
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]?
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.
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.
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:).
Umbraco 8 Language Woes
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:
I have tried using the following which I think is equivalent, but nothing is pulled back:
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)
Please use below code its work fine for you.
Edit: Where intlHomePage would be the Models Builder class name of your current document type.
Reference link
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]?
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.
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, indeedcontent.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 simplecontent.GetName("de")
overload.Adding this to my list!
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:).
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")
is working on a reply...