Selecting block rendering on a content area

  • Updated

Problem: How to make the CMS display different "display options" for different Block / ContentArea fields.

e.g: A news block that has multiple views: Detail, Call to Action, Summary with three display options for this block as well. In the Content Area that sits in side bar, one displays the summary display option. In the Content Area that sits in the center of a page the detail and summary display options should show.

Based on this post, we have to do some extra things:

Create custom content area tag attribute: main, sidebar

We use this attribute to specific the content area position. We will use this value to filter the Display Option values later (see the classes in Custom\Attributes folder).


            GroupName = SystemTabNames.Content,
            Order = 320)]
        public virtual ContentArea MainContentArea { get; set; }

            GroupName = SystemTabNames.Content,
            Order = 330)]
        public virtual ContentArea SidebarContentArea { get; set; }

Register Display Options

Use DisplayOptions service to Add Detail, Summary, Call to Action options in InitializationModule (Custom\Initialization\DisplayOptionsModule.cs)

public void Initialize(InitializationEngine context)


            var displayOptions = ServiceLocator.Current.GetInstance<DisplayOptions>();


                    .Add("detail", "Detail", CustomDisplayOptions.Detail, "", "epi-icon__layout--full")

                    .Add("summary", "Summary", CustomDisplayOptions.Summary, "", "epi-icon__layout--two-thirds")

                    .Add("cta", "Call to Action", CustomDisplayOptions.CallToAction, "", "epi-icon__layout--one-third");


Create Block with SupportedDisplayOptions attribute

[ContentType(DisplayName = "MyBlock", GUID = "066bd7ea-57d4-4dc1-b6a6-4c1537167588", Description = "")]

    public class MyBlock : BlockData, ICustomRenderingContent


        public virtual string Title { get; set; }

        public virtual XhtmlString Content { get; set; }


        public virtual ContentReference Image { get; set; }

        public string[] SupportedDisplayOptions




                return new[] {








RestStore – SupportedDisplayOptionsStore

This is where the client script is located to to get the available Display Option items – Custom\Rendering\SupportedDisplayOptionsStore.cs

Custom Scripts: Register Store, DisplayOptionSelector

The difference with Mattias’s post is that you don’t use cache to store Display Options here. So, the CacheManager.js file in not needed in this scenario. Also, you need overwrite the Episerver ContentAreaEditor.js.

Let see the script files in ClientResources folder of the solution.

The below is the test solution result. The Ascend 2018 March 11-March 14 block can be display in main and side bar content in difference views and display options.