Accessing entry point page when using custom page providers

In EPiServer

This post is about how to retrieve the entry point page reference when the page data object is served from a custom page provider. We have a look at Page Providers in EPiServer CMS, the DataFactory class and finally how to wrap it all up by extending the PageData class.

Page Providers in EPiServer CMS

Custom page providers in EPiServer CMS are used when you need to add pages in EPiServer CMS from a different data source. Note that using custom page providers with EPiServer CMS requires an enterprise license.

Allan Thraen’s Northwind provider which serves pages from the popular sample Microsoft database and the XmlPageProvider are just two examples of when and how to create custom page providers.

Scenario

Your site implements one or more custom page providers. The entry point page, which is a standard EPiServer CMS PageData object, contains data relating to pages served from the custom page provider.

In order to access the data we need to fetch the page reference of the entry point page.

In this sample we use EPiServer CMS 6 and the sample XmlPageProvider which is available for download at EPiServer world.

Page Provider Configuration

We configure two instances of th e XmlPageProvider. The entryPoint setting defines the ID of the page in EPiServer CMS from which our custom pages should be served as child pages. See the image below.

image

The XmlPageProvider serves a single page beneath each entry point page as seen  in the image below.

image

The DataFactory class

With the XmlPageProvider configured we need to query the virtual pages from which entry point page they are served from. Fortunately we can access the current page provider from the DataFactory class. See sample code below.

Extending PageData

To make it easy to access the entry point page from a custom page provider we want to extend PageData to include a method that does just this. See sample code below.

With this extension method we can now query CurrentPage which is of the type PageData. See sample code below.

With the friendly URL rewriter switched off we can see the page ID of the page served by the XmlPageProvider.

image

image

Any data that child pages to the custom page provider require, stored on the entry point page, can now be retrieved by using the extension method.

Thanks for reading!

daniel
daniel
Developer
Recent Posts
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search