Try our conversational search powered by Generative AI!

Ben  McKernan
Jun 12, 2015
  5939
(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
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

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog