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.

3 Answers 3


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.

  • I did enable the Administration theme module which worked nicely - thanks. Dec 30, 2011 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');

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']);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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