Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Pipeline processor to add help text to a field in Sitecore.
using System;
using System.Linq;
using System.Web;
using Sitecore.Diagnostics;
using Sitecore.Globalization;
using Sitecore.Mvc.Presentation;
using Sitecore.Pipelines.GetChromeData;
namespace DEG.SC.ExperienceEditor
public class AddFieldHelpText : GetChromeDataProcessor
public override void Process(GetChromeDataArgs args)
Assert.ArgumentNotNull(args, "args");
Assert.IsNotNull(args.ChromeData, "Chrome Data");
if (!"field".Equals(args.ChromeType, StringComparison.OrdinalIgnoreCase))
var renderingContext = RenderingContext.CurrentOrNull;
if(renderingContext == null)
var currentRendering = GetCurrentRendering();
if(currentRendering == null)
var parameterKey = args.ChromeData.DisplayName + "_HelpText";
var parameterValue = GetParameterValue(currentRendering, parameterKey);
args.ChromeData.DisplayName += " " + Translate.Text(parameterValue);
private string GetParameterValue(Rendering currentRendering, string parameterKey)
if (currentRendering.Parameters.Any(x => x.Key.Equals(parameterKey, StringComparison.OrdinalIgnoreCase)))
return currentRendering.Parameters.Where(x => x.Key.Equals(parameterKey, StringComparison.InvariantCultureIgnoreCase))
.Select(x => x.Value)
var renderingItemParameters = HttpUtility.ParseQueryString(currentRendering.RenderingItem.Parameters);
return renderingItemParameters[parameterKey] ?? "";
private Rendering GetCurrentRendering()
var contextService = Sitecore.Mvc.Common.ContextService.Get();
if (contextService == null)
return null;
var renderingContext = contextService.GetInstances<RenderingContext>().LastOrDefault();
return renderingContext == null
? null
: renderingContext.Rendering;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.