Friday 12 March 2010

SharePoint 2007: Create and manage custom theme in a flexible way

Recently I started to create a custom theme. As you may know, when you change the theme of a site, SharePoint will get a copy of the chosen theme and place that in the content database.
And that is exactly not what I was looking for. I just want to have one single place where my custom theme is located so I can easily manage and change the theme. This will affect than all sites that are (already) using my custom theme.

Here is how to do this:
  1. Go to 12-hive\TEMPLATES\
  2. A good starting point is to make a copy of an existing theme that’s close to what you want to have. For example make a copy of the VINTAGE folder.
  3. Rename it to e.g. MYCUSTOMTHEME.
  4. Inside this folder, rename the VINTAGE.INF file to MYCUSTOMTHEME.INF.
  5. Open this MYCUSTOMTHEME.INF and replace all ‘vintage’ text into ‘mycustomtheme’ (without quotes).
  6. Add an entry for the MYCUSTOMTHEME in the SPTHEMES.XML

    <DisplayName>My Custom Theme</DisplayName>
    <Description>This is my cool customized theme</Description>

    (Note: the thmycustomtheme.gif image can be created when you are done with customization of your theme. Place this file on 12-hive\TEMPLATE\IMAGES\)

  7. Instead of leaving the theme images and stylesheets inside the MYCUSTOMTHEME folder (12-hive\TEMPLATE\THEMES\MYCUSTOMTHEME) we need to move the images and stylesheets to be able to edit and see our changes immediate.
    a). Create subfolders called MYCUSTOMTHEME inside the following folders:
    ii. \12\TEMPLATE\LAYOUTS\1033\STYLES\ (note: 1033 is dependent on your language)
    c). Move the theme.css (and when using MOSS, mossExtensions.css) to \12\TEMPLATE\LAYOUTS\1033\STYLES\MYCUSTOMTHEME\. These two files you will use for your customizations.
    d). Go to 12\TEMPLATE\THEMES\MYCUSTOMTHEME\. There is one file left (mycustomtheme.inf).
    e). Create a new (text)file, called theme.css and open it.
    f). Add the following lines of code:

    @import "/_layouts/1033/STYLES/mycustomtheme/mossextensions.css";
    @import "/_layouts/1033/STYLES/mycustomtheme/theme.css";

    g). Now, when you set a site theme to your ‘mycustomtheme’, the theme.css you just created (with the import statements) are stored in the content database, but the site will use the the css-files on your file system. Now you are ready to edit your css files.
  8. Remember to refer to the images like: url(“/_layouts/images/mycustomtheme/)
The following pictures shows where the customtheme folders are located:

No comments: