All About Data Templates

Blog | Technical
Written By: Nabil OrfaliPublished On: Jul 05 2016
lightbulb

Creating Data Templates

Creating data templates is very simple if you are using Sitecore Rocks. In the Sitecore Explorer, simply expand your Sitecore instance, expand the master database, expand Sitecore, and then expand Templates. Right-click either Templates or an appropriate folder (ex. User Defined) and click "New Template...".

new data template

Give your template a name. After clicking OK, your template will automatically open. The data template has the following details:

data template fields

You can modify the template icon by clicking on it, this is mainly to help you identify your templates easily. 

You can add Field Sections, and add Fields under those sections. Each field is defined by a Field Name and a Field Type.

Inheritance

Lets say you want to create ten templates, and each template will have similar fields such as "Heading" and "Content", plus some other fields. Instead of manually creating the "Heading" and "Content" fields in each of the ten templates, you can simply Inherit the "Heading" and "Content" fields from the original template and add only the new fields to the new template! 

This is done very easily in Sitecore Rocks by right-clicking on the template, choosing "Set Base Templates...", and choosing the template to inherit from.

Standard Values

With Standard Values you can pre-populate the fields with content each time the template is used to create an item. You can set default values for your template by right-clicking on your template and choosing "Create Standard Values". You can also use tokens to specify default values. For example, in the __Standard Values of your template, you can enter $name under the "Heading" field, which will use the item's name to populate the Heading field instead of typing the template heading yourself. You can also click on a field and choose "Add 'Lorem Ipsum...'" to add placeholder text.

Set Insert Options

By setting insert options, you define the default types of allowed child items which helps authors to build multiple levels of content in the tree quickly while reducing the risk of human error. Setting insert options can be done by right-clicking on the template's standard values item and choosing Tasks -> Set Insert Options.

About the AuthorNabil Orfali
Nabil OrfaliCEO & Founder, Sitecore Strategy MVP
Loading...