Automatically add themes to the SPThemes.xml file

I’m not sure I’ll use themes again over the AlternateCssUrl again in a hurry, but I did decide to take a look at the 10 example themes Microsoft Released in March. I’ll blog about how they look – sometime! (The short answer – some good, some bad, some awful!)

Anyway, I was interested that the themes could all be activated as features. This rather kept with my feeling on how branding should be deployed.

However, some of the themes (though not all) were suddenly available in the ‘Site Themes’ page of my SharePoint system. I knew from experience that this isn’t something that ‘just happens’ – previously, I’ve done it by hand.

EDIT: See the comments – they describe an possible pit fall, but both have articles about how to do the same thing…

I became curious, so I opened up Reflector. I found that there is a method called when the feature is installed to update the SPThemes.xml file:

Add Themes Method

ModificationType is just a private enumeration to tell you whether you are adding or removing an entry from the SPThemes file. This code is called from within a Feature Receiver during FeatureActivated FeatureInstalling (need to check, see comments below)

Anyway, I’ll remember this in case I should need to do similar. Obviously, the original code is probably simpler than the decompiled stuff.

Advertisements
Automatically add themes to the SPThemes.xml file

3 thoughts on “Automatically add themes to the SPThemes.xml file

  1. I thought FeatureInstalled ran on all servers, as the feature is *installed* on all servers of the farm. I thought FeatureActivated only ran on one server. But I could be wrong, I’ve not checked…

    Good comments anyway, guys, both were interesting links. I’ll have to give this a go on a multiserver system and check what the deal with Feature Receivers really is.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s