Defaulting to Shared Layout Editing in Sitecore 8.1

At BrainJocks, we’ve been using both shared and final rendering fields from the page editor (sorry – visual experience editor) since Sitecore 8.0.  BrainJocks SCORE™ includes a toggle in the ribbon when run in Sitecore 8.0 that allows page designers to select between shared and final rendering fields when editing pages and standard values.  At first, this created quite a stir for our content assembly teams, but we adopted some best practices and a plan for when to use each.

We learned through experience that teams should start off a project by using the shared rendering field.  Most projects don’t have a clear path to localization at conception, so it makes sense to go ahead and make the initial site delivery by using the shared field, which can be the basis for the first language specific localization when / if that occurs.

When Sitecore 8.1 arrived, we disabled our own shared / final toggle in favor of the Sitecore feature that performs the same function.  Problem was, the Sitecore editor in 8.1 defaults to final, and there wasn’t a way to change the editor default to shared.  Teams who forgot to toggle the field spent time adding components into the final rendering field only to have to rebuild the page later to move the items into the shared field.

To help our teams, we built this simple processor for the loggedin pipeline to allow us to change the default from final to shared in Sitecore 8.1:

using Sitecore.ExperienceEditor;
using Sitecore.Pipelines.LoggedIn;
using Sitecore.Security.Accounts;
using Sitecore.Web.UI.HtmlControls;

namespace Score.Custom.Pipelines.Editor.ExperienceEditor
{
    public class DefaultToAllVersions : LoggedInProcessor
    {
        public override void Process(LoggedInArgs args)
        {
            if (SkipProcessor(args)) return;

            Registry.SetString(Constants.RegistryKeys.EditAllVersions,
                Constants.Registry.CheckboxTickedRegistryValue);
        }

        public virtual bool SkipProcessor(LoggedInArgs args)
        {
            var user = User.FromName(args.Username, true);
            var existing = Registry.GetString(Constants.RegistryKeys.EditAllVersions);
            return user == null && string.IsNullOrEmpty(existing);
        }
    }
}

And to patch this into the proper place, here’s the configuration patch:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <processors>
      <loggedin>
        <processor mode="on"
          patch:after="*[last()]" 
          type="Score.Custom.Pipelines.Editor.ExperienceEditor.DefaultToAllVersions, Score.Custom" />
      </loggedin>
    </processors>
  </sitecore>
</configuration>
Brian Beckham

I am the President and CEO of BrainJocks. As a Sitecore MVP, I spend most of my time consulting and architecting software solutions for enterprise-level Sitecore projects. Learn more about Brian.

2 comments on Defaulting to Shared Layout Editing in Sitecore 8.1

OliverAugust 2, 2016 - Reply

Thanks for sharing and for picking up this “issue”!

Adventtipp 8 – Was sind Final und Shared Layouts in Sitecore 8? – SitecoreDecember 8, 2016 - Reply

[…] Dass sich damit auch schon andere beschäftigt haben zeigt zum Beispiel folgende Lösung, welche das System standardmässig wieder auf die Bearbeitung des „Shared Layouts“ umstellt („so wie früher“): http://jockstothecore.com/defaulting-shared-layout-editing-sitecore-8-1/ […]

Add a Comment

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

Or request call back