Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

Ben  McKernan
Jun 12, 2015
  5944
(3 votes)

Modifying the default view components

I have recently received a lot of questions via support and on the forums about how to change the components that are available by default in the CMS view, e.g. removing the media component. Most people believe that this is not something we support, which is not strange considering the lack of documentation about it. Linus Ekström blogged about this over two years ago now, you can see that here, so I think it is time for a little reminder about how it is done. Note: the following only works for views that have not been modified by the user, e.g. the user has not added any components to their view.

Via Configuration

The simplest way to add or remove components is via configuration in the web.config. The problem is knowing what a component is called and the area path where it is plugged into in order to make this configuration work. This is most likely the reason for people not knowing that this was possible. The following code will remove the media component from the right panel:

<episerver.shell>
  <viewManager>
    <views>
      <add name="/episerver/cms/home">
        <settings>
          <add name="RemoveMediaComponent" 
               transformationType="Remove"
               definitionName="EPiServer.Cms.Shell.UI.Components.MediaComponent"
               plugInArea="/episerver/cms/assets/defaultgroup" />
        </settings>
      </add>
    </views>
  </viewManager>
</episerver.shell>

As you can see there are a lot of magic strings here. A lot of this information would probably need to be reflected out of the assembly unfortunately. The same code with the transformationType set to Add would add the component to the given plug-in area. Plug-in areas are available as constant strings on the PlugInArea class if you want to add a component somewhere.

Via Code

There is also a way to transform the view via code although I am not sure it is any easier. Basically you can implement a IViewTransformer class and mark it with the ViewTransformerAttribute. This will then run when the view is being loaded so you can add or remove any components then via code.

Jun 12, 2015

Comments

Please login to comment.
Latest blogs
Azure AI Language – Extractive Summarisation in Optimizely CMS

In this article, I demonstrate how extractive summarisation, provided by the Azure AI Language platform, can be leveraged to produce a set of summa...

Anil Patel | Apr 26, 2024 | Syndicated blog

Optimizely Unit Testing Using CmsContentScaffolding Package

Introduction Unit tests shouldn't be created just for business logic, but also for the content and rules defined for content creation (available...

MilosR | Apr 26, 2024

Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024