Monday 9 May 2011

Publishing site with multiple master pages

OK, let's be honest, this is not a common scenario. Usually you can live only with one master page and it should be enough for everyone. But from time to time you run to crazy clients which want to rape the SharePoint and turn it upside down.

You'll need another master page if you want to create page/pages inside SharePoint site which are a quite different from your current master page. It could be a different page structure or look and feel.

To implement multiple master pages you need to:
  1. Install DavidK.SP.Publishing.wsp solution
  2. Create a custom master page
  3. Create a custom page layout which will reference your custom master page. The easiest way to do this is to copy BlankWebPartPage.aspx, then edit the page layout and change the Inherits attribute to:

    DavidK.SP.Publishing.PageLayoutWithCustomMasterPage,DavidK.SP.Publishing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a9645fc7d9034814

    Also, add the MasterPageFile attribute which should contain the path to custom master page. In my case it is the following string:

    MasterPageFile="/_catalogs/masterpage/DavidK_custom.master"


Page layout with a custom master page
That's all, just check in the master page and page layout, approve it and create a new publishing page from this page layout.

Hope this helps,

David

1 comment: