Is there a way to target all child pages under two templates? As in, if template name is "A" or if template name is "B", get the children?
This is what I have, and it only targets one template right now but I want to add some sort of or to it so I can get the child items of another:
Item ContentGroup = CurrentItem.Axes.SelectSingleItem(@"child::*[@@templatename='Section Page']/*[@@templatename='Sub Page Top Level']");
I went to get all child items for templates with the name "Sub Page Top Level" OR "Sub Page Top Level Custom." Is there a way to do this without too much trouble?
You can use logical operator like or
:
/*[@@templatename='Sub Page Top Level' or @@templatename='Sub Page Top Level Custom']
If you are using Linq you can use :
homeItem.Axes.GetDescendants().Where(x =>(x.TemplateID.ToString().Equals(yourId1) || x.TemplateID.ToString().Equals(yourId2));
You can also evaluate your sitecore queryes using Sitecore XPath Builder: To get all items under home item based on 2 templates use:
/sitecore/content/home//*[@@templateid='{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}' or @@templateid='{075AB719-9D9C-4ED0-9100-545E87D830A0}' ]
I suggest you to use templateid not templatename. Few years ago I made some tests and is much faster queries using templateid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With