Adding SEO fields to N2 MVC example

I've been using (a copy of) the MVC example from the N2 trunk. By default, there is no SEO tab. To add this, copy SEODefinitionAppender.cs and TitleAndMetaTagApplyer.cs from the N2.Templates.Mvc project (Services folder) to the example project. Then add the line


to the end of Application_Start in global.asax.cs.
The SEO tab and fields should now appear on the edit page.

The next step is to get the SEO fields into the master page. If there's no code-behind class for the master page, then add one, and derive the class like so:

Site : ViewMasterPage<IItemContainer>, IItemContainer<ContentItem>

Add the following to the class:

protected override void OnInit(EventArgs e)
_titleApplyer = new TitleAndMetaTagApplyer(this.Page, Model.CurrentItem);

public ContentItem CurrentItem
return Model.CurrentItem;

Derive AbstractPage from IItemContainer, and implement the CurrentItem getter by returning "this". Make sure all view pages' view data is derived from AbstractPage or IItemContainer.

13 January 2010