LibrarySites.Banner

Field Editor for Rendering Properties

Sitecore Field Editors are a useful way to focus content authors on a set of related fields. You might have fields that do not appear anywhere on the page (last year I wrote a blog post on how to use Field Editors to edit meta-data). Or you might have a group of related fields that you want a content author to be able to edit at the same time (instead of having to edit field individually).

Field Editors work by displaying fields on the rendering's content item (which is either the context item or the rendering's data source).

But what you if you want to apply the same capability to rendering properties? This post explains how you can do it.

To my surprise, this isn't something that Sitecore supports out-of-the-box. All of the pieces are there, but they needed to be pulled together. Those pieces have been pulled together in the Extensions for Sitecore Client project, which you can get using NuGet.

After you install the module you can add custom experience buttons for your renderings. Here's a walk-through an example.

Create Custom Rendering Parameters

Field Editors are useful when you want to limit the fields that are displayed to a content author. So in order to have a meaningful example, I need to have a rendering with multiple fields that I might want to control in this way.

  1. In the master database, add the following template:
    * Name: My Rendering Parameters
    * Base template: Template/System/Layout/Rendering Parameters/Standard Rendering Parameters
    * Location: Templates/User Defined
  2. Add the following field to the template:
    * Section: Basic Settings
    * Field: Field A
    * Type: Single-Line Text
  3. Add the following field to the template:
    * Section: Basic Settings
    * Field: Field B
    * Type: Single-Line Text
  4. Add the following field to the template:
    * Section: Advanced Settings
    * Field: Field C
    * Type: Single-Line Text
  5. Add the following field to the template:
    * Section: Advanced Settings
    * Field: Field D
    * Type: Single-Line Text

rendering parameters template

Assign Custom Rendering Parameters to Rendering

In order for the custom rendering parameters to be available on a rendering, the custom rendering parameters must be assigned to the rendering.

  1. Select the following item:
    * Path: /sitecore/layout/Renderings/Sample/Sample Rendering
  2. Set the following field value:
    * Section: Editor Options
    * Field: Parameters Template
    * Value: Templates/User Defined/My Rendering Parameters

Create Custom Experience Buttons

When a rendering is selected in Page Editor, a toolbar appears. On this toolbar are the experience buttons that are assigned to the rendering. I need to create my custom experience buttons.

  1. In the core database, select the following item:
    * Path: /sitecore/content/Applications/WebEdit/Custom Experience Buttons
  2. Add the following item:
    * Template: /System/WebEdit/WebEdit Button
    * Name: Basic Rendering Settings
  3. Set the following field values:
    * Header: Basic Rendering Settings
    * Icon: Other/32x32/goblet_gold.png
    * Click: webedit:ext:renderingfieldeditor(title=Basic Rendering Settings,sections=Basic Settings)
    * Tooltip: Edit the rendering's basic settings
  4. Add the following item:
    * Template: /System/WebEdit/WebEdit Button
    * Name: Advanced Rendering Settings
  5. Set the following field values:
    * Header: Advanced Rendering Settings
    * Icon: Other/32x32/goblet_silver.png
    * Click: webedit:ext:renderingfieldeditor(title=Advanced Rendering Settings,sections=Advanced Settings)
    * Tooltip: Edit the rendering's advanced settings

Assign Custom Experience Button to Rendering

Next the custom experience buttons must be assigned to the rendering.

  1. In the master database, select the following item:
    * Path: /sitecore/layout/Renderings/Sample/Sample Rendering
  2. Set the following field value:
    * Section: Editor Options
    * Field: Page Editor Buttons
    * Value: Basic Rendering Settings and Advanced Rendering Settings

Try it out!

Now when I select Sample Rendering in Page Editor I see two additional experience buttons. As always, to see all of the rendering's properties, the Edit the Component Properties button is used.

basic settings button



But now the gold button can be used to display the Basic Settings properties...

advanced settings button



...and the silver button can be used to display the Advanced Settings properties.

edit component properties button


Additional Settings

The WebEdit Button items in the core database are used to specify which rendering properties should be displayed. In the example above I used section names to identify the properties to display. But other options are supported as well.

Multiple Sections

webedit:ext:renderingfieldeditor(sections=Basic Settings|Advanced Settings)

Multiple Fields

webedit:ext:renderingfieldeditor(sections=Basic Settings|Advanced Settings)

Sections and Fields

webedit:ext:renderingfieldeditor(sections=Basic Settings|Advanced Settings,fields=Additional Parameters|Placeholder)