In which case you'd use the property alias this isn't turned into pascal case it maintains the style which the Umbraco property editor creates which is usually camel case. (eg pageTitle not PageTitle)
@foreach(var p in feed.Children)
{
<div class="feedItem">
@{
var itemName = p.pageTitle;
}
@itemName
</div>
}
But the compilation still fails. And I should of course have included the message:
Compiler Error Message: CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'pageTitle' and no extension method 'pageTitle' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)
Ohhh it's a IPublishedContent in which case do the following.
@foreach(var p in feed.Children)
{
<div class="feedItem">
@{
var itemName = p.GetPropertyValue<string>("pageTitle");
}
@itemName
</div>
}
The generic type of string is up to you, seeing as you're doing with in Razor you shouldn't need it as the @ will just call ToString() on render anyway.
How do I get the Page Title of a child document?
I have the following code:
That works fine in getting the name of the child document. But how do I get the Page title of the child?
Hi Jan,
I assume you're using the Umbraco DynamicNode objects.
In which case you'd use the property alias this isn't turned into pascal case it maintains the style which the Umbraco property editor creates which is usually camel case. (eg pageTitle not PageTitle)
Thanks,
Jamie
Thanks.
But the compilation still fails. And I should of course have included the message:
Jan Egil
Hi you are probably using Typed Content. (That is what comes from Model.Content )
which means you need to call
which will get the pageTitle property and if it's not set return a default of the Node Name.
Ohhh it's a IPublishedContent in which case do the following.
The generic type of string is up to you, seeing as you're doing with in Razor you shouldn't need it as the @ will just call ToString() on render anyway.
Thanks. That works.
Awesome fella, make sure you mark the right answer post as the solution as read as this helps people who view these topics later on.
Karma makes the world go round after all. :)
is working on a reply...