Thursday, January 26, 2017

Where Sitecore content editor collapse/Expand value saved? Sitecore registry

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 :)

Wednesday, January 18, 2017

Select Multiple Languages In Publishing Wizard For Old #Sitecore Versions

Now this is the default sitecore feature to select all language in the publishing wizard in the newer version of sitecore.

But still if you are working on the old version of sitecore < 7.2, and want to implement the functionality where you can select all the languages on one click means Select All checkbox in the publishing Wizard? So I am here to help you for the same implementation by this blog.

This blog post is especially for the user who is using older version of sitecore < 7.2.
I was engaged one of the sitecore project which is running on 7.1 version and they are using more than 18 languages in the website and client wanted to such a feature where they can select all the languages by one click means select all checkbox, also should behave like toggle means selectall and unselect all.
So I just digged into the sitecore publishing wizard and found that there is a publish.xml which is rendered in the wizard as iframe, internally it call one page called 

·      \Website\sitecore\shell\Applications\Dialogs\Publish\publish.xml
·      /sitecore/shell/Applications/Publish.aspx?id=%7B110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9%7D 

I got the idea where I need to hook the new checkbox I just added new alllanguage selector checkbox in the publish.xml and wrote one javascript function which calls on click of new checkbox.

Adding a new checkbox was very easy task as below:
Add input tag inside the LanguagesPanel groupbox

<Groupbox ID="LanguagesPanel" Header="Publish Language" Margin="0px 0px 16px 0px">

              <input id="SelectAlllanguages" style="margin-left: 8px;position: relative;top: 6px;" value="All-langauges" type="checkbox"/>
              <span style="    position: relative;top: 4px;font-weight: bold;">
                <Literal Text="Select All Language" />
              <Border Padding="4" ID="Languages"/>

Now the only thing is to plug the javascript code with newly added checkbox. On the click of selectall checkbox, all the below checkbox should be checked or unchecked.

So below is the javascript code for the same:

jQuery(document).ready(function ($) {
    $('#SelectAlllanguages').click(function () {
        $('#Languages').find(':checkbox').attr('checked', this.checked);

So after doing some research i am able to give JS reference in the Publish.xml.
I have placed this code in one JS file named publish.js and placed under
And give reference of  jquery library and newly added publish.js file in \Website\sitecore\shell\Applications\Dialogs\Publish\publish.xml file as below

<control xmlns:def="Definition" xmlns="">
    <WizardForm  CodeBeside="Sitecore.Shell.Applications.Dialogs.Publish.PublishForm,Sitecore.Client">
      <Script Src="/sitecore/shell/Controls/Lib/jQuery/jQuery.noconflict.js"></Script>
      <Script Src="/sitecore/shell/Applications/Dialogs/Publish/Publish.js"></Script>

Now check the final result as below:

Newly added checkbox has been added in the list by name: Select All language

On the click of selectall checkbox, all the below checkbox would be checked or unchecked as below:

I hope this article will help you.

Happy Sitecoring

Configure Sitecore 9.1 Content Tagging feature with Open Calais

What is Tagging? Tagging refers to the metadata of the content which is assigned to a content by the content creator and the r...