|Number of votes:||3|
Are you looking for a way of integrating external information/data with an EPiServer Web site? With the release of EPiServer CMS 5 R2 it is possible to integrate EPiServer with most data sources. This is achieved by implementing your own custom page provider.
›› Introduction to page providers
›› Page Providers in short
›› Download XmlPageProvider and xml file
›› Adding the XMLPageProvider to a solution
›› Creating custom page providers
›› XMLPageProvider source code
›› Important to consider
›› Further Information
A page provider is a module that when registered with EPiServer CMS 5 R2 can serve an EPiServer CMS 5 R2 Web site with external data (as PageData objects). An EPiServer CMS 5 R2 site can have several different page provider instances registered, each of them having their own set of configuration data such as capabilities settings. The page provider technology is a new way of integrating external information into an EPiServer CMS 5 R2 Web site. The sample page provider XMLPageProvider is shipped with EPiServer CMS 5 R2.
In this article we shall introduce the concept of page providers and demonstrate XMLPageProvider - a sample page provider aimed at providing insight into how the technology works and hopefully giving you as a developer inspiration to create your own custom page providers. All the data/information appears as part of the EPiServer Web site, though in fact the data/information resides at the data source. The information 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.
You do not need a special license to use custom page providers (e.g. XmlPageProvider) when running the site in a WebDev server. Though in order to host the site in IIS and having your own custom page provider, you are required to have an EPiServer Enterprise license. A non commercial developer license is available immediately - you can request one here at EPiServer licenses, remember to insert the text "Enterpise" in the comment section.
Page Providers in short:
Download the XMLPageProvider (assembly), source code and xml file here on EPiServerWorld.
Here we shall explain how you can add the XMLPageProvider to a Web site, the public templates package has been used as the solution in this demonstration. You only need to perform a few simple steps in order get the XMLPageProvider working in a Web solution:
Insert a page provider node in the site's page tree - we have named the page MyXMLPageProvider. This is the entry point for the XMLPageProvider - observe that it is and must be empty to begin with. Note that the Page ID is given as the value for the entryPoint attribute in the Web.config. The entryPoint attribute specifies which existing page in EPiServer is the root for the pages served by the page provider instance.
Add the assembly XmlPageProvider.dll to the projects references.
Now add the downloaded xml file externalpages.xml included in the zip file to the Web site solution folder, this is used 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. In this demonstration the xml-file exists in the solution folder.
In order to hook up Xml file with the XMLPageProvider in the the solution some configuration needs to be added to web.config. There is no default page provider information in the web.config, this section needs to be added manually. The following is the XMLPageProvider information in the web.config:
<add name="XmlPageProvider" type="CodeSamples.XmlPageProvider, XmlPageProvider" entryPoint="26" capabilities="Create,Edit,Delete,Move,Copy" filePath="~\externalpages.xml"/>
Now you should be able to create, edit, move and delete pages - under the page provider root page, the information will be updated at its source - in this case the xml file.
As the information is moved into a new page provider and is deleted from the old page provider permanently be careful when moving pages from the page provider! In order to be able to move pages from the page provider special permissions must be switched on in: Admin Mode->Security->Permissions for Functions->Allow users to move data/pages between page providers.
A warning dialog will still be displayed as an extra precaution when moving pages from the page provider.
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:
The XMLPageProvider source code can be downloaded and used as inspiration when developing your own custom page providers, it is included in the zip file along with the XMLPageProvider assembly. The XMLPageProvider example implements many more methods than the mandatory four abstract methods. The XMLPageProvider handles pages stored in a Xml file. The following methods are implemented in order to handle the xml data and to create, edit, move and delete pages:
Here are some important points to consider when implementing a custom page provider:
For further information see: