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.

Daylight Saving Delay

Since the clocks went back timer jobs are delayed by 1 hour

So far there is no MS hotfix for this.

http://support.microsoft.com/kb/932563

Error when trying to delete a page layout in MOSS: This item cannot be deleted because it is still referenced by other pages

This info comes from: http://www.katriendg.com/aboutdotnet/Default.aspx?m=1&y=2007

After deactivating & uninstalling a feature (CustomMasterPages) and reinstalling it again the original page layouts & masterpages still remain in the "Master Page and Page Layout Gallery".

Trying to manually delete the files from the gallery gives the following error:

"This item cannot be deleted because it is still referenced by other pages"

The problem is mentioned in the following KB article:

http://support.microsoft.com/?kbid=926812

The KB proposes changing the master page properties to Hidden.

Alternative workaround:

  • Create a new sub-folder in the master page gallery
  • Move the page layout to the new folder using SharePoint Designer
  • Delete the complete folder

Setting the master page for My Site (half way there)

Well it works for me so time for a pint then ;)

Actually there's a small breakthrough; it also works for everyone else, but only on the My Profile page.

To do this open My Site in SharePoint Designer and open the Person.aspx file.

At the top of the page change the master page reference to point to your custom master file:

  • MasterPageFile="_catalogs/masterpage/CustomMaster.master"

This should update all My Sites

Creating a Custom Master Page & Deploying it as a Feature

First of all thanks to Heather Soloman who posted a great article about this Create a Feature: Master Pages for Site Collections.

Here's how i set up the Custom Masterpages and depoyed them as a feature:

Create the Feature

  1. Create a folder called CustomMasterPages under the Features directory on the web server.
  2. Inside the CustomMasterPages folder create the folders:
    • en-us
    • Images
    • Styles
    • MasterPages
    • PageLayouts
    • JavaScript
  3. Copy these two files from the Features directory PublishingLayouts:
    • Feature.xml, and
    • ProvisionedFiles.xml
  4. Create a file in the MasterPages folder called CustomMaster.master
  5. Open CustomMaster.master in notepad and paste the following minimal master page code from Microsoft.
  6. Alternatively Heather Soloman has created another version of the minimal master page which is the version I used in the end. The reason for this is that Heather's version is a stripped out version of the default.master master page which includes all the functionality available. The Microsoft version has only the minimal elements included.
  7. Format the master page with XHTML tags & CSS.
  8. Change the doc type to XHTML transitional.

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/transitional.dtd">

  9. Edit the ProvisionedFiles.xml file to provision the master page, CSS files & images etc.


    <!-- _lcid="1033" _version="12.0.4407" _dal="1" -->
    <!-- _LocalBinding -->
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">

    <Module Name="OSGMasterPages" Url="_catalogs/masterpage" Path="MasterPages" RootWebOnly="TRUE">
    <File Url="tr_portalMaster.master" Type="GhostableInLibrary">
    <Property Name="ContentType" Value="Teleport Master Page - DEFAULT PORTAL LAYOUT" />
    <Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/tr_teleportLogo100.gif, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/tr_teleportLogo100.gif" />
    <Property Name="MasterPageDescription" Value="This is the TelePort master page (DEFAULT CSS LAYOUT) for use with collaboration or publishing sites." />
    </File>
    </Module>
    <Module Name="PublishingLayoutsPreviewImages" Url="_catalogs/masterpage" IncludeFolders="??-??" Path="" RootWebOnly="TRUE">
    <File Url="tr_teleportLogo100.gif" Name="Preview Images/tr_teleportLogo100.gif" Type="GhostableInLibrary">
    </File>
    </Module>
    <Module Name="Images" Url="Style Library/Images" Path="Images" RootWebOnly="TRUE">
    <File Url="tr_telerealLogo102.gif" Name="tr_telerealLogo102.gif" Type="GhostableInLibrary" />
    </Module>
    <Module Name="OSGStyles" Url="Style Library" Path="Styles" RootWebOnly="TRUE">
    <File Url="tr_core.css" Type="GhostableInLibrary" />
    <File Url="tr_portalMaster.css" Type="GhostableInLibrary" />
    <File Url="tr_portalMaster_IE6.css" Type="GhostableInLibrary" />
    <File Url="tr_portalMaster_IE55.css" Type="GhostableInLibrary" />
    </Module>
    </Elements>

  10. Add a preview image to the language folder (en-us).
  11. Create a unique GUID
  12. In the Feature.xml file:
    • Change the feature ID to the unique GUID
    • Change the title to Custom Master Pages
    • Change the Hidden state to False
  13. Recycle the app pool on the WFE website

Deploying the Feature

  1. On the web server (DEV02) launch command prompt and change dir to:

    cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN

  2. Install the feature using STSADM:

    stsadm -o installfeature -name CustomMasterPages

  3. Go to Site Collection Features on the portal top level site and activate the feature.

    To use the master page select from the drop down list on Site Settings / Site Master Page Settings

Redeploying a Feature

Changes made to the feature require that the feature is redeployed. For example; adding new master pages, css files etc. To do this:

  1. On the web server (DEV02) launch command prompt and change dir to:

    cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN

  2. Reinstall the feature using STSADM:

    stsadm -o installfeature -name CustomMasterPages -force

  3. Reactivate the feature in Site Collection Features by deavctivating and the activating it.