I am trying to get a collection of all the child pages which sit in a folder under a page. However, I am struggling with this and CurrentPage.Children returns the folder element (as expected).
I am trying to get all the package (whether domestic or international does not matter, just making it better for the content editors to enter content) and display a few fields from the full package document type on the packages page.
What is the best and neat way in which I can achieve this ?
Thanks, Vishal
One way is get al descedants and filter on the page Level.
@{
foreach (var childchild in CurrentPage.Descendants().Where("Level == " + (CurrentPage.Level+2)))
{
<h2>@childchild.Level @childchild.Name</h2>
}
}
It is also possible to filter on Document Type to ensure you got only the type you want. (the package document type)
Add something like this. .Where("DocumentTypeAlias == \"Package\"")
Combined:
.Where("DocumentTypeAlias == \"Package\" && Level == " + (CurrentPage.Level+2))