Personalization Engine – User Interface
This technical article was first published over 2 years ago and may discuss features and approaches that are no longer relevant for the current version of the platform.
One of the things I wanted to provide with the PersonalizationEngine framework was a series of simple User Interface elements , which would provide an easy way to demonstrate the Personalization Engine within front-end templates, and also provide developers with some simple examples of how to use the API.
Lee Crowe has stepped up to the mark and contributed these for me – Thanks Lee
These User Interface elements are contained in a separate NuGet package: FortuneCookie.PersonalizationEngine.UI (dependent on FortuneCookie.PersonalizationEngine) ,which is available to download the EPiServer NuGet feed.
The packages contains:
1) A custom property, (using Lee’s multiple selection custom property) – which allow you to select a limited set of defined Personalization Engine content providers from which to return content. This allows you to have PersonalizationEngine rules defined on a page-by-page basis.
2) Two dynamic content controls (using the new DynamicContentPlugin attribute) – one which just displays PersonalizationEngine results from the full rule-set, and one which uses the custom property described above to allow a limited sub-set.
FortuneCookie.PersonalizationEngine 1.1
Additionally there is a new version of the core FortuneCookie.PersonalizationEngine, which contains some minor updates and enhancements
1) Added a new event that you can hook into to filter any results prior to them being returned from the PersonalizatioEngine. A good usage for this may be to filter by PageType definition in the case you don’t want your PersonalizationEngine results to contain a particular PageType
The example below will filter all Article pages from any content returned from a PagesWithPageNameContentProvider. The event is hooked on in Global.asax
protected void Application_Start(Object sender, EventArgs e)
{
PersonalizationEngine.OnContentProviderGetContent += PersonalizationEngine_OnContentProviderGetContent;
}
private void PersonalizationEngine_OnContentProviderGetContent(ContentProviderEventArgs e)
{
if (e.ContentProviderType == typeof(PagesWithPageNameContentProvider))
e.ContentProviderPages = e.ContentProviderPages.Where(p => p.PageTypeID != PageTypeResolver.Instance.GetPageTypeID(typeof(ArticlePageType)));
}
2) Changed the call to DataFactory.Instance.GetPages, to an iterated call to DataFactory.Instance.GetPage in the CachedContentProviderBase class. Although the latter method is less performant – there is an acknowledged bug in CMS6R2 which means that PageTypeBuilder does not hook into the GetPages method result meaning that returned results are unTyped.
Both of these packages are now available in the EPiServer Nuget Feed