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

      <add name="/episerver/cms/home">
          <add name="RemoveMediaComponent" 
               plugInArea="/episerver/cms/assets/defaultgroup" />

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


Please login to comment.
Latest blogs
Optimizely SendGrid SMTP host is deprecated

SendGrid is a services for sending email that is included in Optimizely DXP. Previously was the recommended SMTP server to use,...

Tomas Hensrud Gulla | Dec 4, 2022 | Syndicated blog

Hosting Optimizely CMS 12 on Docker Engine

Since Optimizely CMS can now be deployed as a Docker container, here is a demonstration of building, running and scaling an Optimizely CMS 12 site ...

Stefan Holm Olsen | Dec 4, 2022 | Syndicated blog

How to use CacheTagHelper with content areas in Optimizely CMS 12

I might be going out on a limb here - if you have a better solution, feel very free to share it!  Upgrading your Optimizely web application from .N...

Andreas J | Dec 2, 2022

The 1001st Piece in your 1000 Piece Puzzle: .NET Default Interface Functions

I was recently working with a client who wanted a reasonably large subsystem added to Optimizely that would add automated management to their...

Greg J | Nov 28, 2022 | Syndicated blog