Template Settings

Template Settings

Template Inheritance

  • Sitecore data templates do not define all the fields for an item
  • Most Sitecore data templates contain only a single section
  • Almost all data templates are based on other templates
  • Sitecore merges the fields from templates into a superset of fields
  • Sitecore removes duplicate fields

Circular template inheritance

  • A data template is directly or indirectly based on itself
  • Can occur when developers modify the base templates associated with the Standard template or its base templates
  • ASP.NET raises application errors
  • Log entries indicate circular template inheritance detected
  • The system becomes unresponsive, especially when working with data templates

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Settings
  • Sitecore.Configuration.Settings.Templates
  • Sitecore.Data.Items.Item

C# Web Control Code

Sitecore.Data.Items.Item item = this.GetItem();
if (item == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.Write("C# Web Control Real-time Output");

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
//using : for colon and   for space
output.Write("{0}&#58;&#160;{1}", "Item", "<b>" + item.DisplayName + "</b>");
output.RenderEndTag(); //P

string defaultBaseTemplate = Sitecore.Configuration.Settings.DefaultBaseTemplate;
string maxInheritanceDepth = Sitecore.Configuration.Settings.Templates.MaxInheritanceDepth.ToString();

//using &#58; for colon and &#160; for space
output.Write("{0}&#58;&#160;{1}", "Default Base Template", "<b>" + defaultBaseTemplate + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Max Inheritance Depth", "<b>" + maxInheritanceDepth + "</b>");
output.RenderEndTag(); //Div

C# Web Control Real-time Output

Item: Template Settings

Default Base Template: {1930BBEB-7805-471A-A3BE-4858AC7CF696}
Max Inheritance Depth: 16