Scenario:
Applying theme to all the subwebs.
Solution:
A theme is applied at the site scope and is not inherited by child Webs within the site collection. Because of their scoping, themes modify the appearance of all pages within the root Web, including the Site Settings pages. This code sets the Theme for all Webs within a site collection.
Code:
// iterate all sites in the site collectionKnown Issues:
foreach (SPWeb webSite in MSDNSiteCollection.AllWebs)
{
// apply the Lacquer theme
webSite.ApplyTheme("Lacquer");
// update the site
webSite.Update();
}
This will only apply the theme to already existing webs.If you create a new sub-web this will still get the default Theme.
Workaround to that is to create a new Feature at Scope=Site level and execute the above code at activation. That way whenever you create new subwebs.. just deactivate and reactivate the feature.
:-)
0 comments:
Post a Comment