Sitecore gutters are a great way of seeing quick summaries of content within the tree. Some existing gutter options include Locked Items, Workflow State, Missing Versions and more. These can be toggled by right clicking in the left column of the content editor.
Its easy to build custom gutters – in the example above we have a new item available – ‘Custom Presentation’. When this is active on an item it shows:
Behind the scenes there is very little code to achieve this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
using System; using System.Linq; using ###.DataSource.Cms; using Sitecore; using Sitecore.Data.Fields; using Sitecore.Data.Items; using Sitecore.Diagnostics; using Sitecore.Globalization; using Sitecore.Shell.Applications.ContentEditor.Gutters; namespace ###.Domain.Cms.Specialization.Shell.Applications.ContentEditor.Gutters { /// <summary> /// Shows icon if layout field on item doesnt use presentation value set on __StandardValues /// </summary> public class PresentationGutter : GutterRenderer { protected override GutterIconDescriptor GetIconDescriptor(Item item) { Assert.ArgumentNotNull(item, "item"); Field layoutField = item.Fields[FieldIDs.LayoutField]; //ItemKeys.Home is a hard coded Guid elswhere in the app if (layoutField == null || !item.Axes.GetAncestors().Any(a => a.ID.Guid == ItemKeys.Home)) { return null; } if (!String.IsNullOrEmpty(layoutField.Value) && !layoutField.ContainsStandardValue) { GutterIconDescriptor descriptor = new GutterIconDescriptor(); descriptor.Icon = "applications/16x16/document_into.png"; descriptor.Tooltip = Translate.Text("Item doesn't have same presentation as standard values"); return descriptor; } return null; } } } |
Gutters then need to be added to the core database at ‘/sitecore/content/Applications/Content Editor/Gutters‘
Pingback: Bail Bonds 24 Hours Blog