Level: 100
 

Standard Values in Sitecore

Standard values in Sitecore

In this article we’ll describe what standard values are in Sitecore, and how it can be used. We’ll go through the concept and then briefly touch where and how it should be used.

Written by: Jens Mikkelsen
Sun, Aug 22 2010

What is standard values in Sitecore

Standard values were first introduced in Sitecore 5.3 to overcome some of the issues experienced with the predecessors of standard values – “Masters”. In Sitecore 6 masters was completely removed and the concept of standard values took over. You may want to read this old blog post by Thomas Eldblom: No more masters.


Standard values are a way of having default or fallback values for fields in Sitecore, meaning that when items are created, you can specify a field value that should be used by default. This does not only account for custom fields you build, but also standard fields in Sitecore such as presentations and insert options. This means that you can specify a value on the standard values, and when you create a new item which inherits from this template, it will by default use the values specified on the standard values.

 

 

How to create Standard Values in Sitecore

You create standard values on the given template you want to add standard values for. Go to the template and click the options tab then click the standard values button.

 

create standard values in sitecore

 

If the options tab doesn’t appear, when you have selected the template, this is probably because you haven’t selected the builder tab, as it is only when this editor tab is selected that the contextual ribbon will occur.

 

builder editor tab

Now that you have clicked the Standard Values button, there will automatically be created a subitem to the template called “__Standard Values”. This item is based on the template you created it from, and it is as such an actual item. You can change any field in this item, and then this will be the standard value for every item based on this template.

If you go to the template, you will see that the template points to the __standard values item and this is how Sitecore determines what item should be used for standard values:

 

template pointer to standard values
 

This means that you in theory can rename or move the __standard values item, but I wouldn’t recommend doing so, as the “__standard values” name is hardcoded some places in the Sitecore API (at least for Sitecore 6.2).

 

Example of usage of standard values

If you go to your standard values item and enter a value in a field and then create an item based on the template, you will see that the text is filled in:

 

standard values example sitecore

 

Another thing you will notice is the gray text next to the title which says “Standard values”. This is an indication for the editors, that this value is not actually set on the item, but pulled from the standard values.


When the editor changes the value and clicks save, the entered value automatically overrides the standard value of the field. When the standard value has been changed once, it cannot be restored by leaving the field empty. This is due to the fact, that it must be possible for an editor to leave the field blank.


Some fields have a little button in top of it, which says clear. If this button is clicked the standard values will be used again. If there isn’t a “clear” button – like on the single line text field – the editor can go to the “versions” tab and click “reset” in the Fields chunk. Then a dialog will appear where the editor can restore the standard values of whatever field(s) he or she likes:

Reset standard values sitecore

 

If you add standard values for a template, and there already exists item based on this template, the standard values will be used, if the field has not been changed at some point or another by an editor.

 

Tokens in Standard Values

It is possible to enter tokens in the fields on the standard values, and then these will be replaced with other values, when the item is created. For instance you can let the name of an item be filled into a title field. This is done by entering the token $name in the field:

 

replace name token

 

Now when you create a new item based on the NormalPage template, the name entered in the create item dialog will automatically be filled into the title field.


One thing you need to be aware of is that when you enter a token as a standard value, Sitecore will not replace values on already created items. Instead the value “$name” will be used in all the items, which hasn’t changed value since creation.


By default there are the following tokens available in Sitecore:
 

  • $name: Is replaced with the name of the created item
  • $parentname: Is replaced with the name of the parent to the created item
  • $date: Is replaced with the current date
  • $time: Is replaced with the current time
  • $now: Is replaced with current date and time
  • $id: Is replaced with the id of the created item
  • $parentid: Is replaced with the id of the parent to the created item.
     

You can add custom tokens yourself, which is described on Alistair Deneys blog

 

Standard values best practice

Besides using standard values for making the solution more user friendly for the editors, there are a couple of best practices, which you should follow, when using standard values. The concept should almost always be used for two other things: Assigning presentations and insert options. By following this advice, you will make your solution much more maintainable. Read more about assigning presentations to standard values in this blog post by Thomas Eldblom  and read more about assigning insert options to standard values in this post by Alex de Groot.

 

 

Please rate this article


4 rates / 4,5 avg.

  • About the author:

    Jens Mikkelsen

    Jens Mikkelsen is a partner at Inmento Solutions a Sitecore consulting firm. He works as a Sitecore specialist and consulting helping clients architect and build quality Sitecore solutions using the newest modules and tools. 

    Further he has been deeply envolved in various complex solutions and has built up a strong knowledge of Sitecore architecture and best practices. He has especially focused on and is specialized in debugging and analyzing Sitecore solutions.

     

    Jens is very interested in the technical mechanisms in the new marketing products such as Sitecore DMS and Sitecore ECM.

    My Sitecore Freelance CV

7 responses to "Standard Values in Sitecore"

Nice and clear article!

One important thing to note is that standard values is language sensitive. One needs to set the value on every language in order to get the values for that language on the item. This is often forgotten in the heat of development.

/Larre
Posted: Tuesday, August 24, 2010 9:46 AM
Informative and nice article!

One thing to notice is that standard values are language specific. One must set the value on every language where the value should be used.
This is often missed in the heat of development.

/Larre
Posted: Tuesday, August 24, 2010 9:49 AM
:-D
A couple of double postings there. Maybe it would be nice with some kind of feedback showing the post.
Posted: Tuesday, August 24, 2010 9:53 AM
Thanks for your post, Jens. A lot of useful details to consider. I wanted to share some information with you and your community about Sitecore's new best practice blogging initiative that we're launching soon:

http://www.sitecore.net/en/Community/Marketing-Blogs/Focus-on-Community/Posts/2010/08/Best-Practice-Blog.aspx

Do any of the (15) best practice topics interest you as a contributor?
Posted: Tuesday, August 24, 2010 11:12 PM
Thanks for posting this. None of the documention I could find explained how to do this.
Posted: Wednesday, January 19, 2011 7:54 PM
Nice and useful. Thanks :)
Posted: Tuesday, February 17, 2015 5:21 AM
$name displaying in front end.While titile having actual value still i can see my default value coming on front end.

Thanks in advance
Posted: Friday, February 17, 2017 1:17 PM

Leave a reply


Notify me of follow-up comments via email.
 
 
#nbsp;