Maximum Tree Depth

Maximum Tree Depth

MaxTreeDepth

  • This setting identifies the maximum allowed depth of items in the Content Tree. The default is twenty levels.

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

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

Configuration Settings

<configuration>
   <sitecore>
      <settings>
         <setting name="MaxTreeDepth" value="20"/>
      </settings>

C# Web Control Code

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

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

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

string maxDepth = Sitecore.Configuration.Settings.MaxTreeDepth.ToString();
output.Write("{0}&#58;&#160;{1}", "Maximum Tree Depth" + "<b>", maxDepth + "</b>");

output.RenderEndTag(); //Div


C# Web Control Real-time Output

Item: Max Tree Depth

Maximum Tree Depth: 20