Represents an item.
For a list of all members of this type, see Item Members.
System.Object
Sitecore.Data.Items.BaseItem
Sitecore.Data.Items.Item
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
An item is a record in a database. Items are the basic building block of a Sitecore site. An item may represent any kind of information, e.g. a piece of content, a media file, a layout etc. Items always have a name and and ID that uniquely identifies the item within the database. Items have a template that defines which fields the item contains. An item represent a single version of piece of content is a single language.
An item can be retrieved from a database using Items.
An item may have a number of subitems or children. These child items can be accessed through the P:Children property. The resulting items are checked for security and workflow before being returned. So while an item may have subitems, the current user may be denied access to them. The Parent property define the single parent item of this item.
An item represents a single version in a single language of a piece of content. The language of the item can be obtained from the Language property, while the version is available from the Version property.
The item must be in Editing state before the name or any field values can be changed. If not, an exception is raised. To enter the Editing state use the BeginEdit method and to end it, use the EndEdit method. The EditContext class can be used as a shortcut to BeginEdit/EndEdit.
A new item can be added to the children collection using the Add method. A new item must have a name and a template or a master.
The item can be deleted using the Delete or Recycle methods. The Recycle method moves the item to the Recycle Bin database while Delete removes the item permanently.
The position of the item in the content tree, can be retrieved using the Paths property. The full path of the item is available in the Path property.
The Appearance property defines the visual appearance of the item, such as display name and icon.
Using the Axes property other items relative to this item can be retrieved. For instance to determine if an item is an ancestor of the item, use the IsAncestor method.
To determine if a user has permissions to this item, use the Access property. This will check both security settings and workflow state, if any.
A custom item reflect a template and is based on CustomItem. Custom items have an implicit converter from the Item class. For instance the MasterItem class represents a master and add the functionality to add a master to an item. Website or module builder can implement new custom items.
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;
}
This example creates a new item.
public Item AddItem(Item parent, string name) {
Item result = null;
TemplateItem template = Sitecore.Context.Database.Templates["Document"];
if (template != null) {
result = parent.Add(name, template);
}
return result;
}
Namespace: Sitecore.Data.Items
Assembly: Sitecore.Kernel (in Sitecore.Kernel.dll)
Item Members | Sitecore.Data.Items Namespace