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

No comments:

Post a Comment