Tuesday, February 21, 2012

Site Master Page not inherited

issue is described by vmrao: http://social.technet.microsoft.com/Forums/en/sharepoint2010customization/thread/45558c20-f28a-4122-9316-f2e8949e841e

Looking for hard solution to ensure that ideally, subsites (including teamsite and custom site def) have publishing enabled (stapled) and their site template is inherited (in addition to system).

Alternately, that subsite in PI site collection inherits the site and system master page.

workaround is to create a feature receiver to explicitly set master page web properties with code as follows:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
string outmsg = string.Format("Ready to re-direct master page uri for this web {0}",web.Name);
log.Write(outmsg);
SPWeb rootweb = web.Site.RootWeb;
Uri masteruri = new Uri(rootweb.Url + "/_catalogs/masterpage/mycustom.master");
web.MasterUrl = masteruri.AbsolutePath;
web.CustomMasterUrl = masteruri.AbsolutePath;
web.Update();
log.Write("Reset master page URI successful");
}

}

Then create a stapler assigned to GLOBAL

Master Pages and Publishing Feature

Do:

staple publishing feature to STS#0 (team site): http://www.akgroup.com/Blogs/Lists/Posts/Post.aspx?List=184bd7d7%2D27ac%2D4790%2D98d5%2D74b3d754ee52&ID=40

Don't:

use a master page in a site definition that was saved from SPD: http://www.heathersolomon.com/blog/archive/2008/07/23/Master-Page-Error-from-Exporting-file-from-SharePoint-Designer.aspx

have any src="_controltemplates..." in the master page directives. they should be replaced with ~/_controltemplates... : http://social.technet.microsoft.com/Forums/en-US/sharepoint2010customization/thread/4bdd211b-4cb0-48ac-a2c7-226c5c5e2938/