Gets the list of subitems.
An subitem can be retrieved by its ID, name or index in the collection.
The position of an item in the collection can be determined by using the IndexOf method.
To sort the collection like the Sitecore client, use the Sort method.
The collection can be converted to an array using the ToArray method.
To test if an item has children, do not use Children.Count > 0 - use the HasChildren method instead as this increases performance.
The list is filtered so that items which the current user does not have access to are omitted.
This example gets the names of the subitems that has the Document template.
public string GetDocumentNames() {
string result = "";
Item item = Sitecore.Context.Database.Items["/sitecore/content/Home"];
foreach(Item child in item.Children) {
if (child.Template.Name == "Document") {
result += child.Name + ",";
}
}
return result;
}
Item Class | Sitecore.Data.Items Namespace