Return to doc.sitecore.com

Valid for Sitecore 5.3, 5.1.1
Standard template shown as base template

Q:

When we create a template without the base template (see the code snippet below) the Item.Fields returns the number of items as if the template is the base template.

Also if we look at the created template in the client, we can see that the "Standard template" is shown as the base template even though the base template field is empty. Why does this happen?

Sitecore.Context.SetActiveSite("shell");

Sitecore.Context.Domain.Login("admin","");

Database database = Factory.GetDatabase("master");

Response.Write("database.Name = " + database.Name);

Item templateRoot = database.Items["/sitecore/templates"];

TemplateItem template = database.Templates.CreateTemplate("templateFieldColl", templateRoot);  

A:

There are a lot of problems with templates that do not inherit from the Standard Template. Such items will not have workflow, publishing, security and so on (which is quite a problem for the Content Manager).

To solve this, a new setting has been created in the web.config which specifies the default base template to use when one hasn't been assigned.

If someone needs to create a template which doesn't inherit from the Standard Template, the feature can be turned off by setting the DefaultBaseTemplate value to the empty string in web.config.