Up to this point we have not yet needed a new masterpage for our SharePoint Site Definition. We have a theme that some of our customers will use depending on their corporate SharePoint branding.
Currently I change the 'SiteLogoUrl' in my 'FeatureReceiver' on the 'FeatureActivated' event using the following code.
public override void FeatureActivated(SPFeatureReceiverProperties properties) {
AddThemeToSpThemes(THEME_ID, THEME_NAME, THEME_DESC, THEME_IMAGE, THEME_IMAGE);
SPWeb site = properties.Feature.Parent as SPWeb;
if (site != null) {
site.AllowUnsafeUpdates = true;
site.SiteLogoUrl = site.Url + "images/thLogo.gif";
site.Update();
}
}
FeatureActivated is not the best event to trigger on, I would prefer a theme applied event but I can't seem to find one. Perhaps I am not approaching this correctly.
Applying a theme doesn't have an event.
You may be doing this backwards (although the obvious way). How about having your feature receiver activate the theme programmatically, as well as setting your logo?
Note you can store the currently applied theme in the SPWeb's property bag - see this for an example, but storing the current master pages before changing them.
It is worth considering using the Alternate CSS instead of Themes too. That can also be set on you SPWeb object (AlternateCssURL).