HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Describe content in the UI

Describes ways to control how content is presented and behaves in the Optimizely Content Management System (CMS) user interface. Content is a central feature in Optimizely products.

In Optimizely Content Management System (CMS) version 7.0, the content system was introduced to use the central types of pages and blocks in CMS. Since the Optimizely 7.5 release, the Optimizely Customized Commerce catalog and Media system have been delivered as content.

UI descriptors

To make content types display and behave differently, you can use UI Descriptors to describe the appearance and behavior of a content type, such as setting the icon used to display items of the type. The following code illustrates how objects of the custom type ContainerPage behaves in the user interface by specifying the CSS classes used to display the item, such as in listings or trees.

[UIDescriptorRegistration]
public class ContainerPageUIDescriptor: UIDescriptor<ContainerPage> {
  public ContainerPageUIDescriptor(): base("epi-iconObjectPage") {}
}

Inheritance

The type descriptor supports inheritance so that when behavior is not defined on the specific type, it checks parent type descriptors for a description of the requested behavior. For example, if a page type does not specify a custom icon, then the generic icon for pages is used.

Sticky view

"Sticky view" means that the previously used view is loaded when navigating the content tree instead of the default view. The sticky view functionality is enabled by default for every content item. If the content item should not use a sticky view and has its default view, the EnableStickyView property should be set to false.

📘

Note

You should enable the feature for as many content types as possible or turn it off for all content types. Mixing the true and false flag between content types may make the sticky view behavior seem inconsistent to editors, as there is no way for editors to know if the sticky view is enabled or disabled on a content item.

For example, if Optimizely should force the All Properties view to be the default view for the StartPage type instead of the previously used view, then EnableStickyView should be false and DefaultView should be set to AllPropertiesView.

[UIDescriptorRegistration]
public class StartPageUIDescriptor: UIDescriptor {
  public StartPageUIDescriptor(): base(ContentTypeCssClassNames.Page) {
    DefaultView = CmsViewNames.AllPropertiesView;
    EnableStickyView = false;
  }
}

Resources

You can add type-specific translations for the user interface for creating, moving, or deleting items.

The following example sets some generic "fallback" texts for any content, some more specific texts for blocks, and specific texts for "YouTube blocks" (assuming that this is a type in your solution). It defaults to a language node under contenttypes with the name of the type without a namespace. You can change the key by defining the LanguageKey property of your type descriptor; for example, if you have classes in different namespaces with the same class name.

<language name="English" id="en">
  <contenttypes>
    <icontentdata>
      <name>Content</name>
      <create>New Item</create>
      <move>Move Item</move>
    </icontentdata>
    <youtubeblock>
      <name>You Tube Block</name>
      <create>New You Tube Block</create>
      <move>Move You Tube Block</move>
    </youtubeblock>
  </contenttypes>
</language>

Content repository descriptors

CMS has a content repository descriptors entity to standardize components that show content from repositories. This class describes a repository so that the UI can auto-generate with the settings for a repository. You can create navigation components, such as the page tree, or selection widgets, such as the page selector. The following example shows how the implementation for the block repository descriptor:

using System;
using System.Collections.Generic;
using EPiServer.Core;
using EPiServer.Framework.Localization;
using EPiServer.ServiceLocation;
using EPiServer.Web;

namespace Samples {
  [ServiceConfiguration(typeof (IContentRepositoryDescriptor))]
  public class BlockRepositoryDescriptor: ContentRepositoryDescriptorBase {
    public static string RepositoryKey {
      get {
        return "blocks";
      }
    }
    public override string Key {
      get {
        return RepositoryKey;
      }
    }
    public override string Name {
      get {
        return LocalizationService.Current.GetString("/contentrepositories/blocks/name");
      }
    }
    public override IEnumerable<ContentReference> Roots {
      get {
        var roots = new List<ContentReference> {
          SiteDefinition.Current.GlobalAssetsRoot
        };
        if (SiteDefinition.Current.GlobalAssetsRoot != SiteDefinition.Current.SiteAssetsRoot) {
          roots.Add(SiteDefinition.Current.SiteAssetsRoot);
        }
        return roots;
      }
    }
    public override string SearchArea {
      get {
        return "CMS/blocks";
      }
    }
    public override Type[] ContainedTypes {
      get {
        return new Type[] {
          typeof (ContentFolder), typeof (BlockData)
        };
      }
    }
    public override Type[] MainNavigationTypes {
      get {
        return new Type[] {
          typeof (ContentFolder)
        };
      }
    }
    public override int SortOrder {
      get {
        return 200;
      }
    }
    public override string[] MainViews {
      get {
        return new [] {
          HomeView.ViewName
        };
      }
    }
  }

The following example shows how to use the content repository to create a content selector for blocks within the repository:

using EPiServer.Core;
using EPiServer.Shell.ObjectEditing.EditorDescriptors;
using EPiServer.Web;

namespace Samples {
  [EditorDescriptorRegistration(TargetType = typeof (ContentReference), UIHint = UIHint.Block)]
  public class BlockReferenceEditorDescriptor: ContentReferenceEditorDescriptor<BlockData> {
    public override string RepositoryKey {
      get {
        return BlockRepositoryDescriptor.RepositoryKey;
      }
    }
  }
}

The following example shows how to set up a component in the assets panel of the CMS main view that shows content from the repository:

using EPiServer.Shell.ViewComposition;

namespace Samples {
  [Component]
  public class SharedBlocksComponent: ComponentDefinitionBase {
    public SharedBlocksComponent(): base("epi-cms.component.SharedBlocks") {
      LanguagePath = "/episerver/cms/components/sharedblocks";
      SortOrder = 100;
      PlugInAreas = new [] {
        PlugInArea.DefaultAssetsGroup
      };
      Categories = new [] {
        "cms"
      };
      Settings.Add(new Setting("repositoryKey", BlockRepositoryDescriptor.RepositoryKey));
    }
  }
}