In the starter kit using xpath builder, how do I get all the items that inherit from the 'Site Section' template under the Home item?
When I run the following:
/sitecore/content/home/*[@@templatekey='product section']
one item is returned /sitecore/content/Home/Products
which makes sense, however, the following does not return anything:
/sitecore/content/home/*[@@templatekey='site section']
What I'm trying to do is build a menu from the items that inherit the 'Site Section' template using asp.net web control instead of xslt.
Any ideas?
Thanks, Tarek
** UPDATE
Provide more info on the question:
Item /sitecore/content/Home/Products
has template /sitecore/templates/Starter Kit/Site Sections/Product Section
which has a base template of /sitecore/templates/Starter Kit/Item Types/Site Section
If I want the Products and References (similar to Products) items under Home I would run the following query:
/sitecore/content/home/*[@@templatekey='product section' or @@templatekey='references section']
Is there a way to get the item under Home that has Site Section as the base template. In xslt there is a method sc:GetItemsOfType('site section',$home/item)
which does it.
** Answer
var homeItem = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.StartPath);
var siteSectionItems = new List<Item>();
foreach (Item item in homeItem.Children)
{
var itemTemplate = TemplateManager.GetTemplate(item);
if (itemTemplate.InheritsFrom("Site Section"))
siteSectionItems.Add(item);
}