Sitecore 5.0 API

Database.Templates Property

Retrieves templates from the database.

[Visual Basic]
Public ReadOnly Property Templates As TemplateRecords
[C#]
public TemplateRecords Templates {get;}

Remarks

A database may define a number of templates.

A template defines the schema of an item. A schema describes which fields an item has and may contain default values for the fields, for instance a layout definition. Fields are grouped into sections that describe related fields. Templates supports inheritance.

Templates can be retrieved either using their ID or a path relative to the template root, e.g. "System/Folder".

Example

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;
}

See Also

Database Class | Sitecore.Data Namespace