An Introduction to Page Providers
The page provider technology is introduced as part of the EPiServer CMS 5 R2 release. The technology is one way of integrating information into an EPiServer CMS 5 (R2) Web site. A sample page provider XMLPageProvider is shipped with EPiServer, aimed at giving inspiration to developers when creating custom page providers.
An EPiServer Enterprise license is required in order to add your own custom page provider to a commercial solution. However no license check is performed when using WebDev server meaning it is possible to develop custom providers locally without an enterprise license.
The page provider acts as an intermediary connecting an EPiServer site to an external data source. All the data appears as part of the EPiServer Web site, though in fact the data resides at the data source. The data handled by the page provider can be displayed as EPiServer pages only. There is no default page provider information in the web.config - this information needs to be added manually.
For further information see the Tech Note on Page Providers.
Page Providers in short
- Data resides in original store
The page data is not stored in the local EPiServer Web site database, the data source is integrated with EPiServer. - Requires coding and configuration
Registered page providers need to inherit from the PageProviderBase class. Configuration/registration of a page provider shall be added to the web.config. - Sample page provider available
The XMLPageProvider sample page provider is shipped with the EPiServer CMS 5 R2 release. (We have not decided how XmlPageProvider will be distributed, it might require a separate download, but it will be freely available in some way.) - Pages only
The information/data from a page provider appears as EPiServer pages only. - Requires Enterprise License
Commercial solutions implementing a custom page provider require an EPiServer Enterprise License - though not for examples such as the XMLPageProvider. - LocalPageProvider technology
EPiServer uses the page provider concept internally as well, that is the local pages served by the EPiServer database is also delivered through a page provider: LocalPageProvider. The sample XMLPageProvider is a custom page provider. - RemotePageProvider technology
A RemotePageProvider integrates one EPiServer Web solution with another. An EPiServer site can have several different Remote Page provider instances registered with each of them having their own set of configuration data such as binding and capabilities settings etc. The Remote Page Provider is based on WCF framework. - Enable/Disable Page Provider Functionality
In order to be able to move pages between page providers special permissions must be switched on in Admin mode: Permissions for functions: "Move between page providers". A warning dialog is displayed as an extra precaution when attempting to move pages betwen providers.
Custom Page Providers and the PageProviderBase class
Each page provider that is registered with EPiServer must inherit from the PageProviderBase class that resides in the EPiServer.dll assembly.
When creating custom page providers there are four abstract methods that are required to be implemented:
GetLocalPage: What is used to pull out one specific page from the data store and return it - a PageData object or an instance of an object that is derived from the PageData class. There are some helper methods in PageProviderBase to initalize and populate PageData objects.
GetChildrenReferences: Only passing back the page references for all the children to one specific node (the rest EPiServer takes care of - caching, sorting etc).
Uri ResolveLocalPage(PageReference, out Guid): From a pageReference to a GUID. If the passed in identifier corresponds with an identifier for a page served by the page provider instance then this method should return the internal (“classic” link to the page and the Guid based identifier for the page. This maps to PageLink, PageGUID and LinkUrl properties for a PageData instance.
Uri ResolveLocalPage(Guid, out PageReference): From a GUID to a pageReference. If the passed in identifier corresponds with an identifier for a page served by the page provider then the implementation should return the internal ("classic") link to the page and set PageReference identifier. The URI can be constructed by helper method ConstructPageUri(Int32, PageReference). This typically maps to PageLink, PageGuid and LinkUrl properties for a PageData instance.
Integrating the XMLPageProvider
Here we shall explain how you can add the XMLPageProvider to an EPiServer CMS 5 R2 Web site, You only need to perform a few simple steps in order get the page provider working in the solution. Here with have used the XMLPageProvider as an example:
Step 1 - Create a page provider entry point:
Insert a page provider node in the site's page tree (an empty page) - an entry point for the page provider. Note the Page ID which shall be the entry point value in the page provider configuration.
Step 2 - Add the XmlPageProvider Assembly to the solution:
Add the assembly XmlPageProvider.dll to the projects references.
Step 3 - Add the data source:
The xml-file "externalpages.xml" is available for download in EPiServerWorld prepared as the data storage for this demonstration. The path and file name for the data file is stored in the attribute filePath in the path provider configuration in the web config file.
Step 4 - Add the configuration to web.config:
See the configuration of page providers section below.
Now it should be possible to access and manipulate the information in the page provider node in EPiServer. Which actions can be carried out on the page provider node is defined by the capabilities attribute in the configuration. Be careful when moving pages between one page provider to another - when the information is moved into another page provider it is deleted from the old page provider permanently.
Configuration of Page Providers
The configuration for page providers is to be placed in the in web.config. See the page providers tech note for information on which capabilities a page provider instance can support. Some attributes are mandatory (name, type, entryPoint) while others are optional (capabilities, iconPath, wastebasketName). It is possible to add extra attributes needed for the page provider type, these will be passed in to the provider instance upon construction of the instance. Here is an example page provider configuration:
<episerver xmlns="http://EPiServer.Configuration.EPiServerSection">
...
<pageProvider>
<providers>
<add name="XmlPageProvider" type="CodeSamples.XmlPageProvider, XmlPageProvider" entryPoint="26" capabilities="Create,Edit,Delete,Move,Copy" filePath="~\externalpages.xml"/>
</providers>
</pageProvider>
...
</episerver>
Further information in SDK
For further information see the SDK framework reference PageProviderBase class methods for some detailed information regarding the XMLPageProvider implementation.
See Also
For further information see the Tech Note on Page Providers.