I wondered if you would be able to help. I currently have nested pages and what i want to do is write a query that gets the latest 5 child items from a given node id (included nested child items - so essentially all nested children not just direct children).
For context I am currently using this: startNode.Children.Where("Visible"), but I want to exclude children that have the type LandingPage, and ensure its the latest 5 StandardPages.
So you can see there is the concept of Descendants, which will return not just the children of the node but the children of those children etc etc.
There is an overload for Descendants which takes the 'nodeTypeAlias' of the type of content you want to return; since you only need StandardPages then I think
Macro Help
Hi Guys,
I wondered if you would be able to help. I currently have nested pages and what i want to do is write a query that gets the latest 5 child items from a given node id (included nested child items - so essentially all nested children not just direct children).
For context I am currently using this: startNode.Children.Where("Visible"), but I want to exclude children that have the type LandingPage, and ensure its the latest 5 StandardPages.
Any help is greatly appreciated.
Regards Craig
Hi Craig
I really found the Umbraco Razor syntax cheatsheets really handy when I was trying to build more complex queries to see what is possible:
https://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets
and also the documentation on Querying: https://our.umbraco.org/documentation/Reference/Templating/Mvc/querying
So you can see there is the concept of Descendants, which will return not just the children of the node but the children of those children etc etc.
There is an overload for Descendants which takes the 'nodeTypeAlias' of the type of content you want to return; since you only need StandardPages then I think
should get close to what you are after ?
regards
Marc
is working on a reply...