Jan 18, 2012

About SharePoint 2010 MasterPages

I seem to have dropped bits and pieces of information, here and there, on the MasterPages in SharePoint 2010 and where and how they are and ought to be used when creating a custom UI solution. Time for a summary, here's a few words about the MasterPage usage and inheritance.
  1. There are two different MasterPage settings: the site MasterPage and the system MasterPage
    • Site MasterPage is used by publishing sites
    • System MasterPage is used by foundation sites and e.g. list views also on publishing sites
  2. The two above can be the same, or they can be different, e.g. if the publishing sites have no or a custom left navigation (or the publishing site version of the left navigation), the list views and foundation sites need a master with the quicklaunch navigation
  3. If there is a special MasterPage for the TopLevelSite (e.g. intranet front page), which often is the case (when it is not sufficient to simply hide elements from a special front page PageLayout), set this one first, and then you will need to set the MasterPage separately for each second level site because of the inheritance behavior described below
  4. While all other sites are fine with these one or two masters, the search site needs its own, for by default it uses the minimal.master, so we need to have a custom MasterPage derived from the minimal.master in order to show all elements on the page as should be
  5. About the inheritance:
    • Publishing sites automatically inherit the MasterPage from its parent site
    • When the Publishing feature is turned on for a foundation site, it too inherits the (system) master of its parent site
  6. When activating the custom UI feature with a MasterPage-setting feature receiver, the MasterPages will be set for all existing foundation sites, but not the ones created after this
  7. The MasterPages are referenced in a feature receiver or event receiver as
    • Site Master : CustomMasterUrl
    • System Master: MasterUrl
As to how to create a custom UI solution, see Creating a Custom UI Solution for SharePoint
and for instructions on creating a feature receiver and event receiver for masterpages, see Setting MasterPages to Sites Automatically.

No comments: