Tailwind Logo

Standard Values - Part 1 Initial Values

Experience Manager (XM)

Published: 2022-04-19

We've previously covered creating components by specifying field types. Now, we'll introduce Standard Values, allowing setting default values to streamline editing efforts for content editors.

This feature isn't specific to Sitecore Headless but is a standard Sitecore functionality. If not configured, it's essential to consider suitable settings based on operational needs.

How to set up Standard Value

The Standard Value mechanism can be used when you want to set a standard value for an item when it is created. This can be set in the template definition screen and is set as the initial value when the item is created.

The following pages provide more details.

The first step is to set a text field with the same data as the item name as the data when the item is created. We will use the template /sitecore/templates/Project/sitecoredemo/jp/Data/TextSample that we created previously. The creation of this is introduced in the following page.

Once the target template is specified, the builder options appear in the menu items. When you open the ribbon, you will see the Standard Values and Menu.

standardvalue01.png

Clicking on the menu will create a blank item with the item __Standard Values added as an item one level below the template. This will be the item you define for the initial data when creating a new one.

standardvalue02.png

This time, for the singlelinetext1 item, enter the setting $name and save the standard value.

standardvalue03.png

This completes the initial value setting.

Create another standard value for the template /sitecore/templates/Project/sitecoredemo/jp/Data/DateNumberSample. The value is in the form of $date at the date.

standardvalue04.png

Token

In the above section, we have introduced sudden values in the form of $name and $date, and these parameters are called tokens. Sitecore では以下のトークンが用意されています。

Token

Value

$name

Item Name

$id

Item ID

$parentid

ID of the parent item

$parentname

Parent Item Name

$date

System date yyyyMMdd

$time

System time HHmmss

$now

Date and time yyyyMMMddTHHmmss

Verification

First, we want to create an item using the TextSample template we just created. This time, we will create an item with the following name.

standardvalue05.png

When created, the item name is entered as is for singlinetext1.

standardvalue06.png

This is an easy way to do this, putting in the name of the item when the item is created. Then create the item using the `DateNumberSample` template.

standardvalue07.png

The finished product will be in the form that today's date is specified in the date section.

standardvalue08.png

Summary

In this article, we introduced the movement of standard values as a way to set initial values when an item is created. In this case, we specified a token in the form of $name $date, but it is also possible to set a standard value. By using this kind of functionality, you can simplify your daily content creation work.

Tags