User login

Use the admin theme for Drupal help pages

This code goes in a module (not in template.php).

<?php
/**
 * Implements hook_init().
 *
 * Set help pages to the admin theme.
 */
function examplecustommodule_init() {
  if ($admin_theme = variable_get('admin_theme', 0)) {
    if (arg(0) == 'help') {
      global $custom_theme;
      $custom_theme = $admin_theme;
      // Appears to be unnecessary: init_theme();
    }
  }  
}  
?>

We change "examplecustommodule" to the name of our own module.

(This doesn't have to be a custom module... could be a proper contrib module. Actually should be a patch to the administration theme functionality in Drupal core.)

Searched words: 
use admin theme for help pages drupal template.php switch themes administration theming of help page

Comments

Add admin.css

Thanks for the snippet. When you look at system.module, you see that admin.css is added after switching to the admin theme. It seems logical to do that in your custom module as well:

<?php
/**
 * Implements hook_init().
 *
 * Set help pages to the admin theme.
 */
function examplecustommodule_init() {
  if ($admin_theme = variable_get('admin_theme', 0)) {
    if (arg(0) == 'help') {
      global $custom_theme;
      $custom_theme = $admin_theme;
      drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
    }
  }  
}  
?>

Work fine !

Thanks a lot, work fine with drupal 7 !

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.