Skip to main content

Devops

Defaulting to Shared Layout Editing in Sitecore 8.1

Wooden Layout@1x.jpg

At Brainjocks, now Perficient, we’ve been using both shared and final rendering fields from the page editor (sorry – visual experience editor) since Sitecore 8.0.  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>

Thoughts on “Defaulting to Shared Layout Editing in Sitecore 8.1”

  1. Pingback: Adventtipp 8 – Was sind Final und Shared Layouts in Sitecore 8? – Sitecore

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Brian Beckham

As a Sitecore MVP, Brian spends most of his time consulting and architecting software solutions for enterprise-level Sitecore projects.

More from this Author

Categories
Follow Us