This post has been migrated from www.experimentsincode.com, we apologise if some of the images or content is missing

This post has been migrate, original date 12 Oct 2009. Some content is missing. The Sitecore standard template is the base template that pretty much every item you create in Sitecore inherits from. This means that the standard template is a very useful when you need to apply custom fields across every item in Sitecore. I recently had to do this for a project that involve a tagging system where the client wanted to tag everything including media items; I didn’t want to have to add the tagging template to the list of base templates for each item. However there are a few things you have to watch. First to add you custom fields to the Standard Template start by creating a template to contain your custom fields. For this example I have called the template Demo Standard and then added it to the base template of the Standard Template, like so: Missing Image However if you now save this template and look at the Sitecore logs you will notice that Sitecore goes crazy telling you that you have circular template references: Missing Image This is caused because the new template you created inherits from the Standard Template. The solution is to change the base template from which you inherit from. To do this go to the database browser page at http://youdomain/sitecore/admin/dbbrowser.aspx and find your new item. Look at the base templates field and you will see it is empty. The empty space means it will inherit from the Standard Template: Missing Image If we look at the other templates added to the Standard Template we will see that the base template guid entered is an empty guid. So lets enter that into our new template: Missing Image We now see that this stops the errors appearing in the error log. So we can now go to one of our items a check the Standard Fields check box to see our custom fields: Missing Image This is ok but the problem with this solution is that the user has to check the Standard Fields button to see my new custom fields and some users don't even have access to the standard fields checkbox. The way around this is to ensure that the base template guid is not an empty guid. However we have seen that if you enter the guid of another template or leave it blank you get a circular reference problem. You might try just entering a random guid and see what happens, however doing this will cause Sitecore to throw an error because it can’t find the base template you specified. Instead we have to create a dummy template.The dummy template must have an empty guid for its base template like our original template. Missing Image Once you have created this template and changed the base template guid to empty you can now make your original template inherit from this dummy template: Missing Image Now we can visit an item in Sitecore and see that our new custom fields are visible without the user having to check anything. This is because the Standard Fields check box only hides templates that have a base template with an empty guid and our new template does not. All your users should now be able to see this template no matter which item they look at in Sitecore.
comments powered by Disqus