(Jopx has published a nice to know article about master pages: http://jopx.blogspot.com/2007/09/ten-things-you-should-now-about.html )

 

Here are some random interesting notes about master pages in SharePoint Server 2007 and Windows SharePoint Services 3.0:

  1. 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.
  2. 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.
  3. 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
  4. 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)
  5. 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. 
  6. 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.
  7. 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>
  8. 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" />
  9. 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.
  10. 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