Wednesday, July 9, 2008

SP2007: Custom Master Pages on Subsites

While MOSS contains an interface which should allow you to set the master page for all sites, this does not work in practice. Instead you can receive the message "The site master page setting currently applied to this site is invalid. Please select a new master page and apply it"http://support.microsoft.com/kb/936908

To make this work, Microsoft suggests using a Feature to activate the publishing feature on all sites.You don't have to turn on publishing for all subsites. Instead you can use a Feature to apply this master page to the appropriate sites.

The elements.xml file tells MOSS what templates you are going to apply this feature to. Note that the ID listed on all of these lines is the same ID from the feature.xml file in the SubsiteStaplee Feature below. Basically you are using the Stapler feature to associate the Staplee feature with all of the templates listed. You can also add other templates (like your own custom ones)

You should also notice the CSSName Property Key in feature.xml, which in this case is set to a custom sytle sheet in the Style Library. Change this to point to your style sheet and you can apply a style sheet at the same time you apply a master page.

MySiteCreate.dllYou'll aslo need the application which staples the subsite.master to the templates. You can use the MySiteCreate.dll found in the MySiteCreate kit, which you may have already installed if you are using a custom master page on your My Sites. It was designed to staple a master page to a My Site, but can be used to staple a master page to any site.http://www.codeplex.com/CKS/Release/ProjectReleases.aspx?ReleaseId=2824 Drop it in /Windows/Assembly.

Finally register the features in a Command Prompt window:

first change directory to where your stsadm.exe program is, then run the commands: