I’ve been busy lately developing my first full codeplex project. I now feel good enough about that process to have released a version on CodePlex earlier today. So say hello to SharePoint 2010 Site Styles.
Now you may be asking yourself…
What is this and why did you build it?
So with the release of SharePoint 2010 Microsoft decided that the concept of themes should be reworked within SharePoint, and they definitely needed it. So now themes allow you to modify the color and font scheme of any SharePoint site either through the browser or even through Office applications such as PowerPoint and by doing so you can produce a theme file with a .thmx format. This has made sharing, deploying and creating themes extremely easy.
But… what if you wanted to deploy your own custom CSS or your own custom images? Well, you can do one of the following:
- Create your own master page and add your CSS.
- Modify the master page through SharePoint designer and add your CSS.
- Add your CSS in through a web part or other element.
- Turn on publishing and set the alternate CSS file.
- Create a Control Template that’s feature activated to embed your custom CSS file into the page.
Ok, so now you read through that list and realize that only option 5 has any merit what-so-ever because the rest either require publishing or are not deployable/reusable.
So where does SharePoint 2010 Site Styles come in?
It all starts in Central Administration. By activating the farm feature “Site Styles Administration” you are presented with some additional links and a new list to manage all of your site styles across your entire farm. Any change in this list triggers an event handler which pushes the entire list contents (in XML form) into a property at the Farm level. The nice thing about the farm level property bag is that it is read only to all users… not security escalation required!
Now that you have your new Site Style deployed it’s time to use it on an existing site or site collection. Let’s jump over to a site collection of your choice and activate the feature “Site Styles” which is scoped to the Site Collection. By doing that you’re now going to see a new link in Site Settings sitting under the Look and Feel section. This link allows you to manage the site style for this site and all sites underneath it.
Once you click that apply style button a Control Template is going to render the currently seleted style based on some information that has been stored in the current webs property bag, otherwise known as magic!