A content provider is a module that when registered with Optimizely Content Management System (CMS), can serve the site with external data as
IContent objects (for example
PageData instances). A 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 CMS through
ContentOptions.Providers or the
EPiServer.Core.IContentProviderManager API interface or through , which is located through IOC container.
A custom content provider cannot deliver the start page, root page, and waste basket (recycle bin, trash).
You configure content providers in web.config. You can add attributes for the content provider type, which are passed into the provider instance when the instance is initialized. To register the content provider in web.config, add an entry to the configuration element
contentProvider as shown in the following example:
<episerver> ... <contentProvider> <providers> <add name="custom" type="CustomServer.PageStore, Custom" entryPoint="52" capabilities="Create,Edit,Delete,Search,Wastebasket"/> </providers> </contentProvider> ... </episerver>
Some attributes are mandatory (name, type) while others are optional (
entryPoint– Specifies which existing page in CMS is the root for the content served by the content provider instance. The given
entryPointmust not have any existing children in CMS. If the content provider does not give an entry point, it does not appear in the
PageTreein 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
iconPathattribute is _custom.gif*.
wastebasketName– The name of the content provider's Recycle 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
Edit– Edits existing content. This capability implies that the class should implement the
Delete– Removes (deletes) existing content. This capability implies that the class should implement the
Copy– Replicates content internally within the content served by the content provider. To support copy between providers, the capability to support is
Copycapability implies that the class should implement the
Move– Moves content internally within the content served by the content provider. To support move between providers, the capability to support is
Movecapability implies that the class should implement the
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
DeleteLanguageBranchmethod and that the implementation of
Savehandles multiple languages. It also should take passed-in
ILanguageSelectorin consideration when serving content.
Search– Looks within the properties for the content served by the provider. This capability implies that the class should implement
FindPagesWithCriteriaif it implements
IPageCriteriaQueryServiceand if it inherits
Security– Checks access for content delivered by the provider (through calls to
ISecurableinterface on the
IContentinstance). For providers that have an
entryPointand is not supporting Security capability, the access check is performed on the page that was specified as the
entryPointfor the provider. Pages served by the provider instance inherit the access control list (ACL) from the
entryPointpage. If the content instance does not implement
ISecurableand 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
Delete, then you can delete content but not move it to a wastebasket.
Each class registered as a content provider must inherit the
EPiServer.Core.ContentProvider base class, which is based on
System.Configuration.Provider.ProviderBase and resides in EPiServer.dll assembly.
EPiServer.Construction.ContentFactory class to create
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
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);
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);
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 CMS database.
Only the default content provider has a full text search implemented. CMS does not index (and therefore does not search) content served by custom content providers.
CMS uses a remote page provider to integrate the content between two installations. Pages appear as any local page even when they are managed by a separate installation.
Updated 5 months ago