How Drupal 5's Administration Theme functionality works

Drupal's administration theme functionality works very simply: if the first argument of the internal path is admin, the custom theme is set to the admin theme.

This suggests that the $custom_theme variable can be set by modules to change to any arbitrary theme, and it will override the default theme.

The setting of custom_theme to admin_theme is done in system module's implementation of hook_menu:

<?php
/**
* Implementation of hook_menu().
*/
function system_menu($may_cache) {
 
$items = array();

  if (
$may_cache) {
/* cut */
 
}
  else {
   
/**
     * Use the administrative theme if the user is looking at a page in the admin/* path.
     */
   
if (arg(0) == 'admin') {
      global
$custom_theme;
     
$custom_theme = variable_get('admin_theme', '0');
     
drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
    }

   
// Add the CSS for this module. We put this in !$may_cache so it is only
    // added once per request.
   
drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
   
drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
  }

  return
$items;
}
?>

Some other places custom_theme pops up, which ears more investigation:

Ebony-II:drupal-5.7 ben$ grep -nHR custom_theme .
./includes/theme.inc:33:  global $theme, $user, $custom_theme, $theme_engine, $theme_key;
./includes/theme.inc:49:  $theme = $custom_theme && $themes[$custom_theme] ? $custom_theme : $theme;
./modules/block/block.module:207:  global $theme_key, $custom_theme;
./modules/block/block.module:214:    $custom_theme = $theme;
./modules/block/block.module:217:    $custom_theme = variable_get('theme_default', 'garland');
./modules/system/system.module:309:      global $custom_theme;

 

Reply
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.