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

Members Public

The Future of Automotive Mobility will be Powered by Open Source Software

Automotive companies are shifting from bending metal to bending bits. Soon they will be offering software and services to complement their manufactured metal. In order to win in the market, they will need to embrace open-source software to build leverage and enhance their offering.

Members Public

How to Host Your Static Website on Amazon S3: Step-by-Step Guide

1. Login to your Amazon AWS account 2. Create a new hosted zone for your domain using Route 53 3. Copy the NS records for this zone to your domain provider (e.g., GoDaddy) 4. Edit your domain on your domain registrar (e.g., GoDaddy) by clicking Set Nameservers 5.

Members Public

Book Review: Drupal 7 Module Development

Well, it’s been a while my Drupal friends, almost 18 months… dusting off this old Drupal 6 blog and time to start posting again. And what better way to get started again than by talking about Drupal 7, by far the best release of Drupal. And with almost 7