SaaS CMS has officially launched! Learn more now.

Ben  McKernan
Jun 12, 2015
  5987
(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
Optimizely SaaS CMS Concepts and Terminologies

Whether you're a new user of Optimizely CMS or a veteran who have been through the evolution of it, the SaaS CMS is bringing some new concepts and...

Patrick Lam | Jul 15, 2024

How to have a link plugin with extra link id attribute in TinyMce

Introduce Optimizely CMS Editing is using TinyMce for editing rich-text content. We need to use this control a lot in CMS site for kind of WYSWYG...

Binh Nguyen Thi | Jul 13, 2024

Create your first demo site with Optimizely SaaS/Visual Builder

Hello everyone, We are very excited about the launch of our SaaS CMS and the new Visual Builder that comes with it. Since it is the first time you'...

Patrick Lam | Jul 11, 2024

Integrate a CMP workflow step with CMS

As you might know Optimizely has an integration where you can create and edit pages in the CMS directly from the CMP. One of the benefits of this i...

Marcus Hoffmann | Jul 10, 2024