Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a site that uses a separate admin theme. I'd like to include a couple additional pages that use the admin stylesheets. How can I apply the theme selectively to these pages. I'd rather do this in hook_init() or template.php. I don't want to add any more contrib modules to the site at this point. Thanks for any illumination.

share|improve this question
up vote 3 down vote accepted

The Administration theme module will do it, but given you'd like to do it yourself, it does cast some light on that path by suggesting the hook_admin_theme_check() and hook_admin_theme_info() hooks.

share|improve this answer
I did enable the Administration theme module which worked nicely - thanks. – starsinmypockets Dec 30 '11 at 15:14

You can use the module Administration theme for that but if you just want to use the admin theme for a single path you can define it in hook_init

 * Implements hook_init().
 * Use the admin theme on path 'batch'
function MODULENAME_init() {
  if (arg(0) == 'batch') {
    global $custom_theme;
    $admin_theme = variable_get('admin_theme', 'garland');
share|improve this answer

If you don't want to enable more modules (like the admin_theme module), and prefer to write a few lines of code to achive the same thing, you can use hook_custom_theme().

e.g. This snippet switches the user to the admin theme when they're viewing the revision comparison report from the diff module.

function MODULENAME_custom_theme() {
  global $conf;
  $args = arg();

  // Set the admin theme when viewing a diff comparison with the diff module.
  if (isset($args[3]) && $args[3] == "diff") {
    return array($conf['admin_theme']);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.