Loading...
Area: Optimizely CMS
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

Note that this is considered as an advanced development feature.

This document contains functional and technical information about the Content Provider concept. A content provider is a module that when registered with EPiServer CMS can serve the EPiServer CMS site with exteral data as IContent objects (for example PageData instances). An EPiServer CMS site can have several different content provider instances registered with each of them having their own set of configuration data such as capabilities settings, etc.

Configuring content providers

The registration of a content provider with EPiServer CMS can be done either through configuration in the episerver section of the web.config or programatically through the API interface EPiServer.Core.IContentProviderManager which can be located through IOC container.

Note that the start page, root page and waste basket cannot be delivered via a content provider.

The configuration for content providers is placed in the in web.config. Some attributes are mandatory (name, type) while others are optional (entryPoint, capabilities, iconPath, wastebasketName). It is possible to add extra attributes needed for the content provider type, these will be passed in to the provider instance upon initialization of the instance.

Every class registered as a content provider must inherit the base class EPiServer.Core.ContentProvider, which is based on System.Configuration.Provider.ProviderBase. To register the content provider in the web.config file, add an entry to the configuration element contentProvider as shown in the following example:

XML
<episerver>
  ...
  <contentProvider>
    <providers>
      <add name="custom"
              type="CustomServer.PageStore, Custom"
              entryPoint="52"
              capabilities="Create,Edit,Delete,Search,Wastebasket"/>
    </providers>
  </contentProvider>
  ...
</episerver>

Mandatory attributes are name, type. The entryPoint attribute specifies which existing page in EPiServer CMS will be the root for the content served by the content provider instance. The given entryPoint must not have any existing children in EPiServer CMS. If an entry point is not given data from the content provider will not be seen in the PageTree in edit mode.

  • iconPath is an optional attribute which makes it possible to display a custom icon in the page tree for each page served by the provider instance. The given path should be a relative path to the folder \Images\ExplorerTree\PageTree\ in the themes folder, for example, if an image custom.gif is placed in App_Themes\Default\Images\ExplorerTree\PageTree, the value of the iconPath attribute should be custom.gif.
  • wastebasketName is an optional attribute for what the Recyle Bin for the content provider instance is called. If not given, the Recycle Bin will have the same name as the provider is registered with.

It is possible to specify which capabilities the provider instance supports. The available capabilities are:

  • Create states if the provider supports creation of new content. This capability implies that the class should implement method Save.
  • Edit states if the provider supports edit of existing content. This capability implies that the class should implement method Save.
  • Delete states if the provider supports deletion of existing content. This capability implies that the class should implement methods Delete and DeleteChildren.
  • Copy states if the provider supports copy of content internally within the content served by the content provider. To support copy between providers the capability to support is Create. The Copy capability implies that the class should implement method Copy.
  • Move states if the provider supports move of content internally within the cotnent served by the content provider. To support move between providers the capability to support is Create and Delete. The Move capability implies that the class should implement method Move.
  • MultiLanguage states if the provider supports that content have multiple language versions. This capability implies that the class should implement method DeleteLanguageBranch and that the implementation of Save handles multiple languages. It should also take passed in ILanguageSelector in consideration when serving content.
  • Search states if the provider supports search within the properties for the content served by the provider. This capability implies that the class should implement FindPagesWithCriteria if it implement IPageCriteriaQueryService if it inherits ContentProvider.
  • Security states if the access checks for content delivered by the provider should be performed on the content itself (through calls to ISecurable interface on the IContent instance). For providers that have an entryPoint and is not supporting Security capability the access check will be performed on page specified as entryPoint for the provider. Practically this can be seen as that the ACL is inherited from the entryPoint page to all pages served by the provider instance. If the content instance does not implement ISecurable and has no entryPoint no access check is performed.
  • Wastebasket states if the provider supports Wastebasket the content served by the provider can be moved to wastebasket. This capability implies that the class should implement MoveToWastebasket. If the provider does not support Movebasket but support Delete capability then you are able to Delete content not move to wastebasket.

Several capabilities can be specified by a comma-separated list.

Move between content providers requires that the user has permission for function "Move between page providers".

Using ContentProvider for implementation

Each class that is registered with EPiServer CMS as a content provider must inherit the class EPiServer.Core.ContentProvider that resides in assembly EPiServer.dll. The base class contains some virtual methods that can/need to be overriden if some capabilities are to be supported.

To create IContent instances the class EPiServer.Construction.ContentFactory can be used.

Searching a content provider instance

If a content provider instance is to be searchable, it must be registered with the Search capability and the class registered must implement FindPagesWithCriteria if it implement IPageCriteriaQueryService if it inherits ContentProvider.

Below is a description on how to call FindPagesWithCriteria depending on which content providers is to be included in the search.

Specific search on one specific or many custom content providers

Searching on a specific Custom Content Provider or even many Custom Content providers is done by adding a PropertyCriteria for each Custom Content Provider to PropertyCriteriaCollection.

Name the property EPI:MultipleSearch and the value should be the name of Custom Content Provider. Example:

C#
PropertyCriteriaCollection crits = new PropertyCriteriaCollection();
PropertyCriteria crit = new PropertyCriteria();
crit.Name = "EPI:MultipleSearch";
crit.Value = "CustomKey";
crits.Add(crit);
DataFactory.Instance.FindPagesWithCriteria(customPageRef, crits);

Search on all custom content providers

Searching on all Custom Content providers can be achieved be by defining only one PropertyCriteria. The name of the PropertyCriteria should be EPI:MultipleSearch and the value should be "*". Example:

C#
PropertyCriteriaCollection crits = new PropertyCriteriaCollection();
PropertyCriteria crit = new PropertyCriteria();
crit.Name = "EPI:MultipleSearch";
crit.Value = "*";
DataFactory.Instance.FindPagesWithCriteria(customPageRef, crits);

Search on deafult content providers

Search on default content provider is typically the one serving content from the EPiServer CMS database. The Searching will work as before if there is not PropertyCriteria with the name EPI:MultipleSearch.

Note that full text search is implemented only for the default Content Provider. This means that content served by custom content providers are not indexed and will not be searchable by using EPiServer SearchDataSource control.

A Remote Page Provider is used to integrate the content between two installations of EPiServer CMS. Pages appear as any local page even when they are managed by a separate installation.

Do you find this information helpful? Please log in to provide feedback.

Last updated: Mar 31, 2014

Recommended reading