This content is archived. See latest version here

Last updated: Mar 31 2014

When working with content in a content area, editors often want to choose how the content should be laid out. This means choosing a rendering template to display the item. Display options let developers specify which rendering templates may be selected in the user interface.

Configuring display options

To make rendering templates available in the user interface, add an EPiServer.Web.DisplayOption to the display options service, which can be accessed as a singleton via the service locator.

C#
var displayOptions = ServiceLocator.Current.GetInstance<DisplayOptions>();
displayOptions.Add(
    id: "promo", 
    tag: "promo",
    // The name and description properties can also be reference keys to a language resource to allow internationalization.
    name: "Promotion", 
    description: "Promotional content is displayed full width and with background highlighing.", 
    iconClass: "icon-promo"
);

See the EPiServer.Web.DisplayOptions class for more information and method overloads.

Appearance in the user interface

If you add display options to the site, a Display as option appears in the content's context menu within a content area. By default, Automatic is selected. This means that the content uses the rendering template specified by the content area. If the user selects a different display option, that template renders the content.

The display option available for selection in the user interface.

Since all display options are available in the context menu, it is possible to select an option whose tag does not match a rendering template for the content. In this case, a message informs the user that the content cannot be displayed with this option.


Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/