I have this same structure in one of my sites, I used the lovely XPath method of the model node to very easily do what you ask.
For a bonus I also am showing here how to order them by some additional date property we have on our news items (in case natural/sorted order is not desired)...
help for loop through child items
Hello,
I have the following structure in content tree:
en
- footer
- - news (document type "News")
- - - news item 1 (document type "NewsItem")
- - - news item 2 (document type "NewsItem")
Now i want to loop through all news items from a hight located page
I tried the following:
foreach (dynamic item in Model.DescendantsOrSelf().News.Children) {
But this does not work
I have this same structure in one of my sites, I used the lovely XPath method of the model node to very easily do what you ask.
For a bonus I also am showing here how to order them by some additional date property we have on our news items (in case natural/sorted order is not desired)...
Best of luck to you!
Sorry, my post above of course should say var item, with a space, not varitem!
is working on a reply...