Standard values for data template fields

Current version: 10.4

Standard values provide default values for data template fields. If the value of a field is NULL, the item contains the standard value for that field as defined in the data template for that item.

Sitecore stores the standard values for each data template as a child of the data template definition item named Standard Values. Each Standard Values item is based on that data template, defined by its parent data template definition item.

In the following image, the Sample item data template contains the Data data template section definition item and the Standard Values item for the Sample Item data template.

Hierarchy of the Sample item data template showing the standard values item.

The standard values item, like any item based on the data template, contains all the fields defined in the data template itself, plus any fields inherited from base templates. The standard values item contains default field values for items based on the data template. Standard values are used when a field value for an item is set to NULL.

When viewing an item in the Content Editor, any field that contains a standard value is indicated by the token [standard value] immediately next to the field title as shown in the following image.

Indicator in the user interface showing that there is a standard value defined.

Standard values can be inherited from any base template, not just the base template that an item is directly based on.

Tip

To reduce administration and centrally manage system settings, it is best practice to define the following in template standard values rather than in individual items:

  • Layout settings

  • Initial workflow

  • Insert options

Note

If a standard value for a field is set on standard value items for multiple templates an item is based on, only the value from the first template in the inheritance list is used. The values from the other templates are ignored.

The $name token

Sitecore supports the $name token in standard values. Sitecore replaces the $name token with the name of the item during creation. This replacement, however, only takes place during item creation. The item name then becomes the field contents, which replaces the token $name in standard values.

Out of the box, Sitecore comes with the following expand standard values tokens:

  • $name – Name of the item

  • $date – Current server date

  • $time – Current server time

  • $now – Current server date time

  • $id – Item ID

  • $parentid – Item’s Parent ID

  • $parentname – Item’s Parent Name

Note

If a user renames an item, the $name token is not re-evaluated. Therefore, fields that had been assigned a value using the $name will continue to show the original item name even after the item has been renamed. If the field value that has been set using the $name token is reset, the field then shows the value $name and the user must set the field value to something more relevant.

Blank versus NULL field values

When a content author clears a field, such as a text field, this often leaves the field with blank contents, which is not the same as NULL contents. By default, such a field displays a blank value, not the standard value defined for the field.

Field definition items, however, contain a Reset Blank check box. If this is selected, Sitecore replaces blank values with NULL. Therefore, when the Reset Blank check box is enabled for a field, and the user blanks out the contents of that field for an individual item, the field value in that item is reset to NULL and the Content Editor displays the standard value for the field.

Do you have some feedback for us?

If you have suggestions for improving this article,