Really useful Drupal modules: Themekey | Halfnote

Really useful Drupal modules: Themekey

If you have done some development using Drupal, then you would have noticed the abundance of contributed modules available. On this site, I'm going to cherry-pick a few of them as "unusually useful" modules. The next module in line for this is ThemeKey.

In the past year or so, I have created some Drupal themes from scratch rather than using the subtheming method that many people recommend. When doing the theming from scratch, I have typically started with a pretty much empty theme and then gradually built up both content and styling of the theme.

Now, doing theming this way could make life quite complicated. For instance, how do you see your empty or embryonic theme? If you just switch over Drupal to your theme-in-progress, then there is a chance that you will find some difficulties switching back; it is like sawing off the branch you're sitting on. Not good. ThemeKey comes to the rescue.

ThemeKey provides a very easy way for you to associate a theme with a URI path. This means that you can configure Drupal to just use your theme under development for certain pages, while retaining your other theme for the rest of the site. I usually create some test pages and stick them under a URI path like testpages/page1 etc. I often try to do some variations between the test pages to ensure that different sidebar combinations are presented the way they should. I would then use ThemeKey to link my new theme to all pages under the URI testpages.

I would keep things in that way until I get the development of my theme to a point where I know that it can (and will!) give me access to all elements of the Drupal admin UI. At that point, I would switch the new theme over to become the default theme. Usually, there will be further tweaks required in the stylesheets to get everything to look perfect, but that can be done with the new theme in place.

ThemeKey is one of the modules I add to any Drupal installation I set up!