Displaying Item Name in Page Editor via Chrome Data

When working with the Sitecore Page Editor there isn’t anything telling you what Item the Field you are editing belongs to. A content author pointed this out to me so I thought it would be nice to come up with a solution.

I found it was quite easy to add this functionality along with the number of items referencing the Item by manipulating display name that is set in the GetChromeData Pipeline.

Here’s the code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sitecore.Diagnostics;
using Sitecore.Pipelines.GetChromeData;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;

namespace Sitecore.Prototypes.PageEditor.Pipelines.ChromeData
class FieldName : GetChromeDataProcessor
// Fields
public const string ChromeType = "field";
public const string FieldKey = "field";

public override void Process(GetChromeDataArgs args)
Assert.ArgumentNotNull(args, "args");
Assert.IsNotNull(args.ChromeData, "Chrome Data");
if ("field".Equals(args.ChromeType, StringComparison.OrdinalIgnoreCase))
Field argument = args.CustomData["field"] as Field;
string format = "{0}";
Item item = args.Item;
if (item != null)
format = item.DisplayName + " ({0})";
var referenceCount = Globals.LinkDatabase.GetReferrers(item).Count();
if (referenceCount > 0)
format += " " + referenceCount.ToString() + " References";

args.ChromeData.DisplayName = string.Format(format,argument.DisplayName);
if (!string.IsNullOrEmpty(argument.ToolTip))
args.ChromeData.ExpandedDisplayName = string.Format(format,argument.ToolTip);


To configure it add the processor to the pipeline

<processor type=”Sitecore.Pipelines.GetChromeData.Setup, Sitecore.Kernel”/>
<processor type=”Sitecore.Pipelines.GetChromeData.GetFieldChromeData, Sitecore.Kernel”/>
<processor type=”Sitecore.Prototypes.PageEditor.Pipelines.ChromeData.FieldName,Sitecore.Prototypes.PageEditor”/>
<processor type=”Sitecore.Pipelines.GetChromeData.GetWordFieldChromeData, Sitecore.Kernel”/>
<processor type=”Sitecore.Pipelines.GetChromeData.GetRenderingChromeData, Sitecore.Kernel”/>
<processor type=”Sitecore.Pipelines.GetChromeData.GetEditFrameChromeData, Sitecore.Kernel”/>
<processor type=”Sitecore.Pipelines.GetChromeData.GetPlaceholderChromeData, Sitecore.Kernel”/>

Also consider adding this customization by John West and Alex Shyba that fixes an issue with Sitecore not including Datasource References in the Link Database.


About Kevin Buckley
.Net web developer with a lot of experience in CMS. Currently working at Sitecore as Solutions Engineer.

One Response to Displaying Item Name in Page Editor via Chrome Data

  1. alexshyba says:

    You rock Kevin! Thanks, this would be a great fit for the PLF module.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: