Here are some random interesting notes about master pages in SharePoint Server 2007 and Windows SharePoint Services 3.0:
- The first thing you should know about how master pages work in SharePoint is how the "default.master" is used. Default.master is found in the 12 Hive underneath TEMPLATE\GLOBAL\default.master. An instance of this file is created everytime a new site is created in SharePoint.
- Content pages are referring to a master page using 2 different types of tokens: dynamic tokens and static tokens. About dynamic tokens: developers can modify variables in code that change the location of the master page - by changing the MasterUrl (~masterurl/default.master) or CustomMasterurl (~masterurl/custom.master) property. Static tokens point to a certain location where you master page should be found - ~site/custom.master - points to the master page gallery of the current website. ~sitecollection/custom.master - points to the master page gallery of the current site collection. For more info take a look at Customizing master pages in Windows SharePoint Services.
- Administration pages such as viewlsts.aspx, create.aspx etc ... use a different masterpage called application.master which resides in the _layouts folder and so therefore occurs once per installation of SharePoint. So, you will not be able to modify this one on a per site basis
- When you need to create a new master page, start off from one of the minimal master pages - remember though that there is a difference between the master pages for publishing sites and collaboration sites (they have different placeholders- use the Minimal or Base Master Pages guide from Heather Solomon or How to: Create a minimal master page)
- There are a number of ways you can add your own master pages to MOSS - the most modular and flexible approach is by using feature. The nice thing here is that you can create a feature callout event which allows you to change the SPWeb.MasterUrl property from default.master to your custom master page.
- The master page for a Meeting Workspace is a little different then the one for other WSS sites - it uses 3 special controls which are used to display the tab controls.
- Did you know that you can link a master page to a specific site definition? You can do this by specify the MasterUrl property of the Configuration node in ONET.XML e.g. <Configuration ID="1" Name="Blank" MasterUrl="_catalogs/masterpage/custom.master">. Remember that you will also need to provision the master page at site creation by using the Modules section in ONET.XML - <Module Name="CustomMasterPage" List="116" Url="_catalogs/masterpage" RootWebOnly="FALSE"> <File Url="custom.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" /> </Module>
- Be carefull of using inline code blocks in master pages. The code blocks will work fine as long as your masterpage does not get customized. Once it gets customized (e.g. by using SharePoint Designer) it will run in safemode which does not allow inline code. You can override this setting by altering the web.config and adding an extra PageParserPath - <PageParserPath VirtualPath="/sitedirectory/marketing/_catalog/masterpage/*" IncludeSubFolders="true" CompilationMode="Always" AllowServerSideScript="true" />
- Have you seen the mysterious SharePoint DelegateControl in a lot of master pages? These define regions in your master page for which you can substitute the content with your own controls. You can replace what is shown in a delegate control by define a Control element within a feature for more info take a look at Use your ASP.NET webcontrol in MOSS 2007 with SharePoint delegate control.
- There is a feature for WSS 3.0 which you can download from CodePlex to manage your Master Page as well - take a look at Stramit SharePoint 2007 Master Picker.
Some extra white papers and reference material
- Customizing and Branding Web Content Management-Enabled SharePoint Sites (Part 1 of 3): Understanding Web Content Management and the Default Features - This article discusses topics that you should understand before you use Microsoft Office SharePoint Server 2007 to create sites that support Web content management (WCM) and gives a general overview of the various artifacts that are available in the product. (11 printed pages)
- Customizing and Branding Web Content Management-Enabled SharePoint Sites (Part 2 of 3): Extending WCM - This article explains the structure of master pages, the steps to create a custom master page, the underlying mechanisms of navigation in WCM-enabled sites, the creation of custom field controls, and how to customize the Page Editing toolbar.
- Customizing and Branding Web Content Management-Enabled SharePoint Sites (Part 3 of 3): Creating and Configuring WCM-Enabled Sites - This article examines the Web content management (WCM) features of Microsoft Office SharePoint Server 2007 from an administrative perspective: creating a Publishing Portal site, configuring a site for anonymous access and forms authentication, and using site variations. (9 printed pages)
- ASP.NET Master Pages Overview
- Building tylerbutler.com, Part 1: Planning and Basic Branding
- Building tylerbutler.com, Part 2: Building Content Types and Page Layouts
- Building tylerbutler.com, Part 3: Customizing Content Query Styles
- MOSS2007 - Rebuild Corporate Website
- MOSS2007 – Rebuild Corporate Website (Part 2)
- MOSS2007 – Rebuild Corporate Website (Part 3)
- MOSS2007 – Rebuild Corporate Website (Part 4)
- Customizing the Look and Feel of Microsoft Office SharePoint Server (MOSS) 2007 - Custom Chrome / Branding
- How to: Create a Minimal Master Page
- How to Create and Store Master Pages on the Server for Use with Site Collections
- Create a Feature: Master Pages for Site Collections
- CSS Options with Master Pages
- Customizing Sharepoint 2007: Customizing using SharePoint Designer 2007
Hi!
ReplyDeleteGreat article.
Just one question. You state that 'The first thing you should know about how master pages work in SharePoint is how the "default.master" is used. Default.master is found in the 12 Hive underneath TEMPLATE\GLOBAL\default.master. An instance of this file is created everytime a new site is created in SharePoint.' My question is: where is this instance saved? Inside the database, or in the filesystem?
Thank you for the article and all.
Regards