Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi I have a nested content called "footers" on my "Home node". If retrieve the "footers" by:
var stamdata = Model.AncestorsOrSelf("home").First();
and loop them by;
var listofFooters = stamdata.Value<IEnumerable<IPublishedContent>>("Footers");
i get a null
however in my Visual debug it says: count2 and i can view the content.
I can also get all the other values from "Home".
My page declaration is:
@inherits Umbraco.Web.Mvc.UmbracoViewPage
This worked in Umbraco 7xxx but not in Umbraco 8. Do i really need to supply the Home model to my footer?
Hi Jonas
Can you check that property alias is exactly "Footers"? It should be exactly like in Umbraco and it's case sensitive.
Thanks,
Alex
Sure, here goes.... I have changed it back and forth when debugging so thats why it is in capital letters :-)
thanks, Jonas, looks right
Jonas, can you show the content section now? How many items are in nested content property?
Is it one or few ones?
Hi Alex,
I have 2 items right now:
If Home is your top node, and you're using ModelsBuilder (which I strongly recommend), then you could do this
var home = Model.Root() as Home; if(home.Footers != null & home.Footers.Any()){ foreach (var footer in home.Footers) { @footer.Name } }
Thank you Michael
I am using Modelsbuilder and now it works. :-)
Hi Jonas,
If anyone's curious why it didn't work in the first place: nested content returns IPublishedElement in v8.
stamdata.Value<IEnumerable<IPublishedElement>>("Footers")
would have worked.
Cheers!
Guido
Brilliant!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Nested content is empty
Hi I have a nested content called "footers" on my "Home node". If retrieve the "footers" by:
and loop them by;
i get a null
however in my Visual debug it says: count2 and i can view the content.
I can also get all the other values from "Home".
My page declaration is:
This worked in Umbraco 7xxx but not in Umbraco 8. Do i really need to supply the Home model to my footer?
Hi Jonas
Can you check that property alias is exactly "Footers"? It should be exactly like in Umbraco and it's case sensitive.
Thanks,
Alex
Sure, here goes.... I have changed it back and forth when debugging so thats why it is in capital letters :-)
thanks, Jonas, looks right
Jonas, can you show the content section now? How many items are in nested content property?
Is it one or few ones?
Hi Alex,
I have 2 items right now:
If Home is your top node, and you're using ModelsBuilder (which I strongly recommend), then you could do this
Thank you Michael
I am using Modelsbuilder and now it works. :-)
Hi Jonas,
If anyone's curious why it didn't work in the first place: nested content returns IPublishedElement in v8.
would have worked.
Cheers!
Guido
Brilliant!
is working on a reply...