Question: Where Sitecore content editor collapse/Expand value saved?
Answer :  Sitecore registry

Have you ever noticed the Sitecore content editor’s Expand/Collapse section behaviour? Sometime itโ€™s collapsed, sometimes itโ€™s expanded, or your section is always rendered as expanded even you already set as true โ€œcollapsed by defaultโ€ Field from section template , any idea why? How Sitecore determine that value, from cookies? From user preference or from Sitecore registry cache? Yes it set into the Sitecore registry cache.

Sitecore uses Registry.GetBool() for the /Current_User/Content Editor/Sections/Collapsed key to determine whether to collaspsed or expand the content editor section, Yes Sitecore use registry class in the Sitecore.Web.UI.HtmlControls namespace.

Sitecore store and read section collapsed/Expand Boolean value in the registry class as below
   public static class Registry
        public static bool GetBool(string key)
    public static bool GetBool(string key, bool defaultvalue)
    public static int GetInt(string key)
    public static int GetInt(string key, int defaultvalue)
    public static string GetString(string key)
    public static string GetString(string key, string defaultvalue)
    public static void SetBool(string key, bool val)
    public static void SetInt(string key, int val)
    public static void SetString(string key, string value)
    public static string GetValue(string key)
    public static void SetValue(string key, string value)
Below is the logic to collapse or expand the template section in the content editor:

  1. If the user expand or collapse the section.
  2. Sitecore store the value in the registry class using key named /Current_User/Content Editor/Sections/Collapsed
  3. At the time of rendering the content editor section, Sitecore first check the value from registry, if value available, then render the section accordingly means, if user had already expanded any section then next time that section will be expanded only even it set as default collapsed checkbox true in the section template.
  4. If value is not available in the registry, it check the section template  field value called  Collapsed by Default checkbox
  5. If this checkbox checked then section will be rendered as collapsed otherwise it rendered as expanded.

Below is the code snippet of the same condition:
namespace Sitecore.Shell.Applications.ContentEditor
        /// <summary>
        /// Formatter for rendering the editor
        /// </summary>
        public class EditorFormatter
public void RenderSection(Editor.Section section, Control parent, bool readOnly)
            Assert.ArgumentNotNull(section, “section”);
            Assert.ArgumentNotNull(parent, “parent”);
            bool isSectionCollapsed = section.IsSectionCollapsed;
            bool flag = (!isSectionCollapsed ? true : UserOptions.ContentEditor.RenderCollapsedSections);
            this.RenderSectionBegin(parent, section.ControlID, section.Name, section.DisplayName, section.Icon, isSectionCollapsed, flag);
            if (flag)
                for (int i = 0; i < section.Fields.Count; i++)
                    this.RenderField(parent, section.Fields[i], readOnly);
            this.RenderSectionEnd(parent, flag, isSectionCollapsed);
public bool IsSectionCollapsed
                if (this._isCollapsedDetermined)
                    return this._isCollapsed;
                UrlString urlString = new UrlString(Registry.GetString(“/Current_User/Content Editor/Sections/Collapsed”));
                string item = urlString[this.Name];
                if (string.IsNullOrEmpty(item))
                    return this.CollapsedByDefault;
                this._isCollapsed = item == “1”;
                this._isCollapsedDetermined = true;
                return this._isCollapsed;
I Hope this article will help you.

Happy sitecoring ๐Ÿ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *