User login

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;

Resolution

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.