Insights

Enabling Blocks by Default in Episerver Commerce

Enabling Blocks by Default in Episerver Commerce

Enabling Blocks by Default in Episerver Commerce Enabling Blocks by Default in Episerver Commerce
VP, Enterprise Platforms
Valtech
Casper Rasmussen

July 22, 2017

Using Episerver Blocks, to e.g. support re-usable components, in Episerver Commerce content is a very common scenario.

Out of the box, that is indeed also possible. It only requires you to register a ContentReference driven property type – e.g. ContentReference, ContentArea or List – for it to be supported in the authoring interface.

After you’ve done that, you will probably realize that the “Blocks” asset panel in the right hand side pane by default is unavailable to your editors, requiring these to manually go in an add the “Blocks” gadget to their view.

How to enable the “Blocks” panel, by default, in Episerver’s Catalog view

Enabling “Blocks”, by default, in Episerver’s Catalog is very easy. Since it’s not documented anywhere, it’s absolutely worth writing a simply blog post about!

You’ll only need to create a single class, which through Episerver’s component system makes the “Blocks” gadget available for both existing and new content editors.

[Component]

public class SharedBlocksNavigationComponent : ComponentDefinitionBase

{

    public SharedBlocksNavigationComponent() : base("epi-cms/component/SharedBlocks")

    {

        this.LanguagePath = "/episerver/cms/components/sharedblocks";

        this.SortOrder = 150;

        this.PlugInAreas = new string[] { "/episerver/commerce/assets/defaultgroup" };

        this.Categories = (IEnumerable<string>)new string[1]

        {

          "commerce"

        };

        this.Settings.Add(new Setting("repositoryKey", BlockRepositoryDescriptor.RepositoryKey));

    }

}

Original article was posted on Episerver Fellow: 

http://fellow.aagaardrasmussen.dk/2017/07/22/enabling-blocks-by-default-in-episerver-commerce/

Start Living the Dream

Are you an innovative, forward-thinking individual who is eager to push the boundaries of the digital revolution? Valtech is looking for a creative mind like yours.
Explore our open positions
Start Living the Dream