Unfortunately, the master Page section of that chapter was messed up
during copy editing. Did you have problems with the modified steps in
the errata?
Here's the scoop:
Setting MasterPageFile="~masterurl/default.master" in the page directive
of a Template Page will cause WSS to use the MasterUrl property of the
current Web. If the MasterUrl is null/empty string (that is the default)
it will use the default.master page that was loaded into the Master Page
Gallery by the GLOBAL site definition. Note that all list pages use the
files in ..\12\Pages and they use this setting.
Setting MasterPageFile="~masterurl/custom.master" in the Page directive
of a Template Page will cause WSS to use the CustomMasterUrl property of
the current Web. If the CustomMasterUrl is null/empty string (that is
the default) it will use the MasterUrl property. If the MasterUrl is
null/empty string (again, that is the default) it will use the
default.master page that was loaded into the Master Page Gallery by the
GLOBAL site definition. This means that list pages will never use the
CustomMasterUrl property unless you modify Microsoft's pages (not
recommended).
The MasterUrl and CustomMasterUrl properties of a Web can be set on the
Configuration element in a WebTemp*.xml files in ..\12\TEMPLATE\1033, or
on the Configuration element in the ONET.xml file for a site definition,
or programmatically on any SPWeb object. These properties are typically
set to a Mater Page copied (GhostableInLibrary) to the Mater Page
Gallery using something like:
MasterUrl="_catalogs/masterpage/MWSDefault.master"
You can look at ..\12\TEMPLATE\SiteTemplates\MPS\XML\ONET.xml for an out
of the box example of how this can be done. Or, download an example of
how this can be used in a custom Site Definition from my book site: see
my updated VS.NET project here:
developersguide.mindsharp.com/.../Threaded.aspx?Ro
otFolder=%2fLists%2fAskTheAuthor%2fTodd%2c%20before%20I%20waste%20any%20
more%20of%20my%20time%2c%20is%20this%20even%20possible
It is likely to wrap so I've also created a tinyurl:
http://tinyurl.com/3cwzhm
An example of programmatically setting the MasterUrl property in code
can be seen in Stramit's (Renaud Compte) Master Picker It is on
CodePlex: http://www.codeplex.com/SPMasterPicker
The MasterPageFile in the Page directive can also be set to other
values...
Directly to a Master Page in the Master Page Gallery of the current
Site:
MasterPageFile="~site/_catalogs/masterpage/my.master"
Directly to a Master Page in the Master Page Gallery of the current Site
Collection:
MasterPageFile="~sitecollection/_catalogs/masterpage/my.master"
Directly to a Master Page in a virtual location of the current site (in
the root in this example):
MasterPageFile="my.master"
Directly to a Master Page in the _layouts folder (this only works on
pages in the _layouts folder):
MasterPageFile="~/_layouts/application.master"
Sadly, pages in the _layouts folder are completely file system-based and
not stored in the database in any way. They cannot use ~site or
~sitecollection; in fact, they cannot use any Master Page that isn't
also in the _layouts virtual directory.
I have decided to only use MasterPageFile="~masterurl/default.master"
for all my application and list pages. I then currently set my MasterUrl
property using the Configuration element in the ONET.XML file to a
custom Master Page that I copy (Ghostable) to a virtual location (often
just to the root of the current site using a Module element). All the
other possibilities are fraught with downsides, not the least of which
is that the end user can do things to the custom Master Page including
inadvertently deleting it from the browser. Yikes! If I need to change
my Master Page in certain settings, I then do it programmatically. The
only exception to this is when I create admin pages in the _layouts
folder, I am forced to the application.master page or a custom Master
Page that I also save in ..\12\TEMPLATE\LAYOUTS\Custom\MasterPages.
There is more, but that should get you going pretty well. Please ask
follow up questions if I've missed something pivotal.