Monday, April 02, 2007

How to set a custom default master page for all site definitions in WSS 3.0

http://blogs.tamtam.nl/mart/HowToSetACustomDefaultMasterpageForAllSiteDefinitionsInWSS3.aspx

In WSS3 you can set the masterpage of a site using SharePoint designer, just rightclick the new masterpage and set it to default.

This method however, does not set all the new created sites with the new masterpage. So, how can we deploy the new masterpage?

  • Put the new masterpage in the following directory: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL
  • Go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL\XML and open de ONET.XML.
  • At the bottom of the page add a new masterpage entry so it will look something like this:

<Modules>

<Module Name="DefaultMasterPage" List="116" Url="_catalogs/masterpage" RootWebOnly="FALSE">

<File Url="[any name].master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />

<File Url="default.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />

</Module>

</Modules>

This code will automatically put your custom masterpage into the masterpage gallery when a new site is created.

  • Change the default masterpage to the new one. Look for the following line: <Configuration ID="0" Name="Default" MasterUrl="_catalogs/masterpage/default.master"> and change it to your new masterpage.
  • Hit save, and do an IISRESET.

Now create a new site and the new master page is set automatically.

Beware that when you create a master page with SharePoint designer you cannot just export the master page to the filesystem, because it will mess up your master page code. You can better copy the master page code to notepad, and save it as your master page on the filesystem.

4 comments:

  1. its doesn't work for me.....I created master page in Sharepoint Designer and i checkIn that masterpage as Publish as major version and approve it....it works fine for me.......i copy the HTML of that Master page and paste it in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL" with file name MyTest.master

    Then i changed the ONET.XML
    at the end i wrote this in the module tag

    Name="MyTestMasterPage" List="116" Url="_catalogs/masterpage" RootWebOnly="FALSE">
    and in file Tag
    Url="MyTest.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"

    and in configuration Tag i wrote
    ID="0" Name="MyTest" MasterUrl="_catalogs/masterpage/MyTest.master"

    I hit save and reset my IIS
    after this i create a new sitecollection for my WebApplication in SharePoint Central Administrator....i choose the collaborationPortal....but it doesn't work for me.....it gives an error "Cannot complete this action."

    can u plz help me out....where m wrong....

    ReplyDelete
  2. Also, have you thought about deploying your masterpages as features?

    Have a look here

    ReplyDelete
  3. anybody know how to make these updates as part of a feature activation ... rather than manually?

    ReplyDelete