1

This is a question about defining standard values and base templates. Considering the following:

I have a base template B with a field called Title. Is it possible to define the standard value for the Title field on the standard values of template B? And what happens if a templates that inherits from B also has standard values? Does Sitecore pick the most specific/local definition of Title?

I have tried this scenario and sometimes the standard values of B are used and sometimes they are ignored. I have found an article by John West stating this scenario should be ignored here.

It would be nice though to be able to define a standard value for a field in a base template and not on all implementing templates??

6

Standard values are default field values used as fallback, if the item does not have a field value defined. If your item has a field value (even an empty field value), the standard value is ignored. If you want to revert back to the standard value, simply deleting the field value is not enough, since this will just change the field value to empty. Instead, you need to reset the field value (Versions > Reset Fields).

The __Standard Templates item is just an item. If you add a field value here, the standard value from inherited templates (of the given field) is ignored, and your new standard value will be used as fallback for any items inheriting your new template.

This means that you can define standard values on your base templates, and override the standard values in inheriting templates if needed.

  • I try to set the standard values on the 'lowest' template in the inheritance tree. just to avoid having to go through all the base templates to find where the standard value is coming from. – Ruben Verschueren Mar 28 '17 at 11:25
  • That should work, unless any template in between overrides the standard value (even with an empty value). – Kasper Gadensgaard Mar 28 '17 at 11:35
  • +1 for "If you want to revert back to the standard value, simply deleting the field value is not enough." This is super important. – Zachary Kniebel Mar 28 '17 at 20:39
0

You can define the Standard Value for your Title field on Template B. You can use token for putting dynamic values like $name etc. If you plan to use another template that inherits Template B as well - the Standard Value of the Template B would be inherited as well for your Title field.

But you should not inherit template B which already has a Title field on another Template which also has the same field name. Avoid doing that, else Sitecore would read the first occurrence of the field name.

0

The answer by @KasperGadensgaard is 100% correct: if you are inheriting a field and you change its value then clearing the field's value is not enough to restore the inheritance, but rather you must reset the field values via the Versions > Reset (Fields) button in the content editor.

In Sitecore 8+:

enter image description here

In older versions:

enter image description here


Check if a field value is a _Standard Value in the Content Editor

I'm not a big fan of invisible characters impacting my code or content without me knowing. Fortunately, Sitecore understands this problem and was kind enough to provide us with a little message that displays next to the field name to indicate whether or not the field's value is inherited from a Standard Value. When necessary, another indicator in the same location is used to idenitify a field that is "Shared" (i.e. the value is the same across all language versions).

In Sitecore 8+, the indicator looks like this (shown for a "Shared" field):

enter image description here

In older versions, the indicator looks like this:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.