Sitecore 5.0 API

Database.CreateItemPath Method (String, TemplateItem, TemplateItem)

Creates a path of items.

[Visual Basic]
Overloads Public Function CreateItemPath( _
   ByVal path As String, _
   ByVal folderTemplate As TemplateItem, _
   ByVal itemTemplate As TemplateItem _
) As Item
[C#]
public Item CreateItemPath(
   string path,
   TemplateItem folderTemplate,
   TemplateItem itemTemplate
);

Parameters

path
Path that must exist in the database
folderTemplate
Name or ID of template to use when creating folder items (all items except last).
itemTemplate
Name or ID of template to use when creating final item in path.

Return Value

The item corresponding to the last element in the path. Ie. the 'deepest' item.

Remarks

Use this method to ensure that a specific path of items exist in the database.

For each element in the path it is checked if an item matching the element exists. If it does not, a new item is created with the proper name.itemTemplate

See Also

Database Class | Sitecore.Data Namespace | Database.CreateItemPath Overload List