Getting kids children alone

I am trying to list elements that have a given template on the parent page in Sitecore. While I can do this for children, but I also want to include children-children, that is, something under the parent, if he has the selected template, it will work, this is my code in the C # file:

lvThing.DataSource = context.Children.Where(x => x.TemplateName == "cool template").ToList<Item>(); lvThing.DataBind(); 
+7
source share
1 answer

If you need items below the children, you can use the item.Axes.GetDescendants () method to get all the items under the context item.

Then your code should look like this:

 contextItem.Axes.GetDescendants().Where(x => x.TemplateName == "cool template").ToList(); 
+13
source

All Articles