7

I would like to add a field to all of my templates. The easiest approach appears to be to either

  1. Add the field directly to Standard Templates (/sitecore/templates/System/Templates/Standard template) or
  2. Create a new template and add it to the Base Template field on Standard Template (inherit my custom template)

Similarly, if all media items require a particular field, can I modify a low-level media template in a similar manner?

Example:

  • "Media Classification" - (/sitecore/templates/System/Analytics/Marketing Taxonomy/Base/Classification/Media classification)
  • "File" - (/sitecore/templates/System/Media/Versioned/File)

Is it reasonable to modify these Base Templates in certain scenarios?

3 Answers 3

10

Whenever I do this, I create a new template that I inherit. If wanted to add a new field called widget, I would create a new _template called _widgetdata (notice the _ to dictate the fact that this should only be inherited). And in _widgetdata add my widget field.

Now go to /sitecore/templates/System/Templates/Standard template and inherit the _widgetdata template. This will help with upgrades because it will be easy to put back with TDS or a script. Rather than having to keep track on field on the Standard template.

1
  • 2
    +1 for the mention of TDS/Unicorn to make sure the change is not lost after an upgrade
    – jrap
    Commented Jan 29, 2019 at 18:28
3

From my point of view, the answer is yes, you can update the Sitecore Base template or add the template as base.

When upgrading the Sitecore instance, this may impact those templates. You may need to re-add those base templates to the standard field template. You'll need to keep track of the items so that if you are upgrading the Sitecore instance, you'll need to update the template.

However, when performing a Sitecore upgrade using the .update packages, if the standard field template is not updated, it won't remove the inheritance that you've added.

Moreover, it depends on the requirements at hand. For example, if you need to add new fields to the Media item, you'll need to make the default Sitecore Media Template item inherit the fields. Preference here is to create a custom template and then use inheritance.

-1

My humble opinion is that it's not acceptable to modify the ootb item by adding templates via inheritance. The reason for this is purely because you then start introducing parts of the ootb Sitecore tree in to your solution. With that in mind you might as well have other parts of Sitecore imbedded within the solution such as the Sitecore Web root. If 1 item doesn't break your coding standards then neither should 10, or 100, or, heck, just serialise the entire Sitecore database and add it to your solution.

1
  • While you correctly identify that it is a slippery slope, there are valid cases for needing to do this. One example, for instance, is adding the option for content editors to add the X-Robots-Tag header to media items selectively, which would require modifying the File template. If well documented and selective, I think this is a completely valid case, and does not amount to serializing the entire Sitecore database. Commented Jan 29, 2019 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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