Mark Everard

Hello, I'm Mark – a PhD physicist turned technologist / architect.

Archive for June, 2011

London EPiServer Developer Meetup Summer 2011

without comments

Our third London EPiServer Developer Meetup will be held on 7th July 2011, and will be hosted by our friends at Rufus Leonard

Hang on – let me put that in my diary….

Rufus Leonard have kindly offered to be our hosts for the evening, they are based in Farringdon.

I want to push a slightly different approach this time. It would be great if more of you would get involved. I know there is a huge amount of experience and knowledge out there and I’d love for some of you to step up and and share your experiences. Remember that not only are we EPiServer developers, we are also .NET developers, and all also web developers, so there is a really broad range of things that you could share with us. They don’t have to be long talks or even that formal. The most important thing is the sharing (just as  I’m sure your Mother’s always taught you!)

If you’re interested then please sign-up and RSVP using the meetup group below.

Written by mark

June 14th, 2011 at 12:46 am

Posted in Community,EPiServer

An extremely useful Powershell command…..

without comments

By default Powershell exceptions and stderr outputs don’t give you much information beyond the exception name and the position in the script where the exception occurred. What you really want is a full stack trace.

You can get more information by running the following command; immediately after you’re troubled by a ‘troublesome’ exception

$error[0]|format-list –force

Written by mark

June 13th, 2011 at 11:18 pm

Posted in Powershell

Personalization Engine – ContentProvider Criteria Models

without comments

This post explains how to build a custom user interface element for the FortuneCookie PersonaliztionEngine for EPiServer which will describe a criteria to be used within a ContentProvider.

Each ContentProvider possesses a Criteria string property which is set by an editor via the PersonalizationEngine UI and can be used within the GetContent method to specify a search term or more granular content method of retrieval. For example, the PagesInCategoryContentProvider uses the Criteria property to specify a drop down list populated with  the full list of site categories. The selected value of this drop down list is then used as a criteria within the FindPagesWithCriteria method.

This partial view containing the CriteriaModel interface is loaded by an AJAX call made by the PersonalizationEngine Admin user interface when the ContentProvider dropdown is changed.

Building your own CriteriaModel user interface element

The ICriteriaModel interface defines a way for developers to specify the user interface element that should be used by the editor to input the Criteria for each ContentProvider. Ultimately the persisted criteria value will be a string, but it could be entered via any type of HTML element, such as a dropdown list or simple input textbox. The exact CriteriaModel used can be specified in the VisitorGroupContentProvider attribute – if none is specified (or needed) a default CriteriaModel which displays a simple text message is used.

Building your own CriteriaModel involves creating a simple model and a partial view. This utilises a feature of the ASP.NET MVC 2 framework called Display and Editor Template Helpers. This feature provides a way to specify a custom view for any type within your solution (see These partial views are placed in a specific location within your solution and the framework will then use those views to display your type any time it is rendered in a view using the <%= Html.DisplayForModel() %> or <%= Html.EditorForModel() %> html helpers.

Here is an example of the previously mentioned CategoryListCriteriaModel which is used by the PagesInCategoryContentProvider. The model contains the Criteria string property as defined by the ICriteriaModel interface. It also specifies a property that uses the EPiServer API to return the full list of categories. This property is used directly by the partial view.

Standard MVC validation attributes can be marked on the Criteria property which will be honoured by the Personalization Engine (by means of a custom Model Binder).

using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer.DataAbstraction;

namespace FortuneCookie.PersonalizationEngine.EditorModels
   public class CategoryListCriteriaModel : ICriteriaModel
      public string Criteria { get; set; }

      public IEnumerable<SelectListItem>; CategorySelectListItems
               var rootCategory = Category.GetRoot();
               return from Category category in rootCategory.Categories
                        select new SelectListItem() { Text = category.LocalizedDescription, Value = category.Name };

The view itself is very simple, with just a label and the populated dropdown list.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<FortuneCookie.PersonalizationEngine.EditorModels.CategoryListCriteriaModel>" %>
   <%= Html.LabelFor(m => m.Criteria)%>
   <%= Html.DropDownListFor(m => m.Criteria, Model.CategorySelectListItems)%>

The Personalization Engine project contains four ICriteriaModels that you can use in your own implementations

  • CategoryListCriteriaModel – very specific model displaying a dropdown list of EPiServer site categories
  • SearchReferrerCriteriaModel – a simple model displaying a text message. The SearchReferrerContentProvider in this case overrides the Criteria value to pull the criteria value used from the current request’s header.
  • DefaultCriteriaModel – displays a simple message stating “No criteria value necessary”
  • TextBoxCriteriaModel – displays a input textbox and also validates that a value must be entered.

Written by mark

June 6th, 2011 at 8:00 am

Posted in ASP.NET,C#,EPiServer