Customizing Display Menu for blocks

Vote:
 

Hello,

We have a requirement in which we have to add an item to the Display Menu while editing a block. Is this achievable?

#190170
Apr 04, 2018 8:10
Vote:
 

Hi Saurabh,

Just to clarify, when you're asking about the "Display Menu" are you asking about the "Display as" display options menu when placing a block in a content area or the "Select View" dropdown on the top right of the editor (or something else)?

If it's the display options menu used when placing a block in the content area, these options can be set by getting an instance of Episerver.Web.DisplayOptions and calling the "Add" method. You can see an example of this in the Alloy demo site in /Business/Initialization/DisplayRegistryInitialization.cs which is an initialisation module used to register the display options:

[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class DisplayRegistryInitialization : IInitializableModule
    {
        public void Initialize(InitializationEngine context)
        {
            if (context.HostType == HostType.WebApplication)
            {
                // Register Display Options
                var options = ServiceLocator.Current.GetInstance<DisplayOptions>();
                options
                    .Add("full", "/displayoptions/full", Global.ContentAreaTags.FullWidth, "", "epi-icon__layout--full")
                    .Add("wide", "/displayoptions/wide", Global.ContentAreaTags.TwoThirdsWidth, "", "epi-icon__layout--two-thirds")
                    .Add("narrow", "/displayoptions/narrow", Global.ContentAreaTags.OneThirdWidth, "", "epi-icon__layout--one-third");
            }
        }

        public void Preload(string[] parameters){}

        public void Uninitialize(InitializationEngine context){}
    }
#190182
Apr 04, 2018 11:43
Vote:
 

if you use bootstrap renderer - this is done automatically for you :)

#190265
Apr 06, 2018 10:57
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.