Add Help Text to Field in Sitecore Page Editor

It is very common for content authors to need a little extra assistance when entering content through the page editor.  For example, they may be uploading an image and need to know what the recommended dimensions are.  Instead of having to reference an old email from the developers who built the site or dig up an old conversation in Basecamp, you can now provide this information to them right in the page editor.  Below is an example of what this looks like.

ImageWithHelpText

In this post, I will describe how you can add help text to improve your client’s page editor experience.  Please note that this can be extended to include more than just fields, but my examples will focus on fields.

First let me describe how you can define the help text that will be pulled in by the pipeline processor I will be creating.  Above I have a generic content pod.  This template (below) consists of an image, a subheading, some rich text and a link.

ContentPodTemplate

In order to set the help text for a specific field on our template, I will utilize the parameters field on the content pod rendering.  I’ve made the decision to create the keys in the format of [FieldDisplayName]_HelpText.  For example, if I want to set the help text for the image field on my content pod I would do so like below.  Likewise if I wanted to also set the help text for my rich text field (named “Copy”) then I would add another parameter with a key of “Copy_HelpText”.

ContentPodRendering

Now that I have established how the help text will be set, I’ll demonstrate how to pull that into the page editor.

The work of pulling in our help text will need to be done in the getChromeData pipeline.  The processor is shown below.  If you’re interested, an overview of this pipeline and other important ones can be found here.

A quick overview of what’s happening in this processor:

  1. Check the chrome type to make sure I am processing a field. *You can modify this logic to look for placeholders, renderings and more!*
  2. Get the current rendering from the rendering context
  3. Set the parameter key that I’ll be searching for: [FieldDisplayName]_HelpText
  4. Check the current rendering’s parameters to see if it contains a parameter matching our parameter key.  If no match is present, I will check the rendering item itself for a match.  *This gives me the ability to override the help text on specific instances of a rendering!*
  5. If I have found the value corresponding to our parameter key (our help text) then append it to the current display name for our field

Now that I have a pipeline processor to pull in my help text, I need to add it to the getChromeData pipeline.  See config file below.

You can now add help text to fields on your renderings.  Don’t worry, your content authors will thank you later!

Advertisements

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

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