Skip to content

Hot Swapping of Drupal Themes

1 min read

At the ParentsClick Network we are soon to be rolling out many more sites on our platform. Because of our unique community API (which I will be detailing in a future post) we are running many sites (many not yet released) on the same install of Drupal, with the same database, and no shared tables. Yes, no typos there. More on just how that works in a later post.

One thing we have to do is change the theme based on the URL, along with a host of other things. ZivTech recently postedabout changing themes, but for our setup, we need something more low level. Hence this technique.

Edit your settings.php and stick this in at the bottom:

<?php
// if the URL is an administration page
if (strpos($_GET['q'], 'admin') === 0) {    
  $conf['theme_default'] = 'garland';
}
?>

What this does is tell Drupal to load an entirely different theme then the default one. Bonus points if you noticed the Drupal 5 administration theme bug: it shows the admin theme but if you save any form, the theme switches from the admin one to the default one. The above snippet fixes that.

The only catch? Make sure you initialize this in your system table by visiting the themes page and make sure you theme is in the sites/all directory. Otherwise you can run into some funky issues.

Happy theme hot swapping!

codeDrupal

Related Posts

MothersClick Acquired by Lifetime Networks

MothersClick.com [http://www.mothersclick.com/] and the rest of the ParentsClick Network [http://www.parentsclick.com/]have been acquired by Lifetime Entertainment [http://www.marketwatch.com/news/story/l/story.aspx?guid=%7B764B126C-2071-4605-8222-7FA1E481B0EE%7D] . I’ve been working on this site and with Dietrich (CEO & founder) for over 2

news — 5 min read

Leo talks about the new TWiT.tv site

At the end of last week’s TWiT episode [http://www.twit.tv/62], Leo and company talk about the new TWiT.tv site [https://tedserbinski.com/drupal/twit-tv/]. A clip of that can be listened to below. Also last week on the Lullabot podcast [http://www.lullabot.com/podcast]

code — 1 min read

My first 15 min of fame!

A few weeks back, Leo Laporte [http://en.wikipedia.org/wiki/Leo_Laporte] approached Lullabot [http://www.lullabot.com/] about developing the new TWiT website [http://www.twit.tv/]. Well we gladly accepted, I mean, this is Leo! So I was put in charge of developing the new site, and

code — 1 min read