Try our conversational search powered by Generative AI!

Loading...
Area: Optimizely CMS
Applies to versions: 12 and higher
Other versions:
ARCHIVED This content is retired and no longer maintained. See the version selector for other versions of this topic.

Configuring content providers

Recommended reading 
Note: This documentation is for the preview version of the upcoming release of CMS 12/Commerce 14/Search & Navigation 14. Features included here might not be complete, and might be changed before becoming available in the public release. This documentation is provided for evaluation purposes only.

This topic describes the concept of content provider, and how to configure these for Optimizely CMS websites.

In this topic

How it works

A content provider is a module that when registered with Optimizely CMS, can serve the site with external data as IContent objects (for example PageData instances). An Optimizely CMS site can have several different content provider instances registered with each having its own set of configuration data, such as capabilities settings, and so on.

You can register a content provider with Optimizely CMS through ContentOptions.Providers or the EPiServer.Core.IContentProviderManager API interface or through , which is located through IOC container.

Note: A custom content provider cannot deliver the start page, root page, and waste basket (recycle bin, trash).

You configure content providers when register them. You can add attributes for the content provider type, which are passed into the provider instance when the instace is initialized. Following is an example on how to register a custom content provider with configuration values for the provider:

            services.Configure<ContentOptions>(o => o.AddProvider<XmlContentProvider>("xml", config =>
            {
                config[ContentProviderParameter.EntryPoint] = _configuration.GetValue<string>(ContentProviderParameter.EntryPoint);
                config[ContentProviderParameter.Capabilities] = ContentProviderParameter.FullProviderCapability;
                config["someConfigKey"] = "someConfigValue";
            }));

The type of the provider and the name is required. There are some built-in optional configuration values like  (entryPointcapabilitiesiconPathwastebasketName). Then a specific content provider might have it own configuration values.

  • entryPoint. Specifies which existing page in Optimizely CMS is the root for the content served by the content provider instance. The given entryPoint must not have any existing children in Optimizely CMS. If the content provider does not give an entry point, it does not appear in the PageTree in edit view.
  • iconPath. Displays 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 you place an image named custom.gif in App_Themes\Default\Images\ExplorerTree\PageTree, the value of the iconPath attribute is custom.gif.
  • wastebasketName. The name of the content provider's Recyle Bin. If not given, the Recycle Bin has the same name as the registered provider.

You can specify the following capabilities, if the provider instance supports it. You can specify multiple capabilities with a comma-separated list. 

  • Create. Creates new content. This capability implies that the class should implement the Save method.
  • Edit. Edits existing content. This capability implies that the class should implement the Save method.
  • Delete. Removes (deletes) existing content. This capability implies that the class should implement the Delete and DeleteChildren methods
  • Copy. Replicates 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 the Copy method.
  • Move. Moves content internally within the content 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 the Move method.

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

  • MultiLanguage. Supports multiple language versions. This capability implies that the class should implement the DeleteLanguageBranch method and that the implementation of Save handles multiple languages. It also should take passed-in ILanguageSelector in consideration when serving content.
  • Search. Looks within the properties for the content served by the provider. This capability implies that the class should implement FindPagesWithCriteria if it implements IPageCriteriaQueryService and if it inherits ContentProvider.
  • Security. Checks access for content delivered by the provider (through calls to ISecurable interface on the IContent instance). For providers that have an entryPoint and is not supporting Security capability, the access check is performed on the page that was specified as the entryPoint for the provider. Pages served by the provider instance inherit the access control list (ACL) from the entryPoint page. If the content instance does not implement ISecurable and has no entryPoint, no access check is performed.
  • Wastebasket. Moves content served by the provider to wastebasket. This capability implies that the class should implement MoveToWastebasket. If the provider does not support Movebasket but supports Delete, then you can delete content but not move it to a wastebasket.

Using ContentProvider for implementation

Each class registered as a content provider must inherit the EPiServer.Core.ContentProvider base class, which resides in EPiServer.dll assembly. 

Use the EPiServer.Construction.IContentFactory class to create IContent instances.

Searching one or more content provider instances

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

The following example shows how to call FindPagesWithCriteria, depending on which content providers are to be included in the search. To searching on one or more custom content  providers, add a PropertyCriteria for each custom content provider to PropertyCriteriaCollection. Then, name the property EPI:MultipleSearch and the value to the name of custom content provider.

PropertyCriteriaCollection crits = new PropertyCriteriaCollection();
PropertyCriteria crit = new PropertyCriteria();
                 crit.Name = "EPI:MultipleSearch";
                 crit.Value = "CustomKey";
                 crits.Add(crit);
ServiceLocator.Current.GetInstance<IPageCriteriaQueryService>().FindPagesWithCriteria(customPageRef, crits);

Search on all custom content providers

The following example shows how to search on all custom content providers, by defining only one PropertyCriteria and naming it EPI:MultipleSearch with the value "*".

PropertyCriteriaCollection crits = new PropertyCriteriaCollection();
PropertyCriteria crit = new PropertyCriteria();
                 crit.Name = "EPI:MultipleSearch";
                 crit.Value = "*";
                 crits.Add(crit);
ServiceLocator.Current.GetInstance<IPageCriteriaQueryService>().FindPagesWithCriteria(customPageRef, crits);

Search on default content providers

If you do not specify PropertyCriteria with the name EPI:MultipleSearch, search occurs on the default content provider, which is typically the one serving content from the Optimizely CMS database.

Note: Only the default content provider has a full text search implemented. Optimizely does not index (and therefore does not search) content served by custom content providers.

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

Last updated: Jul 02, 2021

Recommended reading