SharePoint 2010 comes with a number of very nice looking site themes. In case you apply one of these themes to the root of your site collection, the theme will not be automatically applied to newly created subsites. My customers usually want one theme to be used and automatically applied across entire site collection.

I created a simple SharePoint 2010 sandboxed solution that will automatically apply SharePoint theme applied to parent site to a newly created site. You only need to download solution, upload and activate it via Solution Gallery… It might take few seconds before new theme is applied.

There is a similar OOTB feature in SharePoint 2010 Server (Publishing Infrastructure), it might give you more options as it allows you to break inheritance and similar stuff.

SharePoint theme automatically applied to subsite

Background for developers

  • This is simple Event Receiver that applies theme on WebProvisioned event
  • SPWeb.Theme Property has been deprecated; use it only when the UI is in backward compatibility mode (SPWeb.UIVersion = 3).
  • Use the code below to change SPWeb Theme
  • Source code for this solution is available at codeplex.com

Code sample

public override void WebProvisioned(SPWebEventProperties properties)
       {
           ThmxTheme theme = ThmxTheme.Open(properties.Web.Site, ThmxTheme.GetThemeUrlForWeb(properties.Web.ParentWeb));
           theme.ApplyTo(properties.Web, false);
           properties.Web.Update();

           base.WebProvisioned(properties);
       }

One Comment

  1. Aseem Says

    Very nice solution! Do you have alternative for SP2013?

    thanks

Leave a Reply