Last updated August 23, 2009. Created by Dublin Drupaller on June 23, 2007.
Edited by SLIU, jhodgdon. Log in to edit this page.

description

These snippets automatically switches your theme to a custom page-admin.tpl.php layout file so a custom administrators theme is activated when needed.

Useful if you're using a fixed-width site design and your administration pages breaks the layout or where you want to add editing tips to where the sidebar blocks normally appear when a user is creating/editing content.

usage

  1. Make a copy of your page.tpl.php file and rename it to page-admin.tpl.php.
  2. Using a text editor like notepad.exe or equivalent, copy the preferred snippet into the template.php in your theme folder.
  3. Edit your page-admin.tpl.php layout file to suit.
  4. Upload your new page-admin.tpl.php layout file and your edited template.php file to your active theme folder

Admin theme switcher

This snippet is not really necessary for Drupal 5.x which has an out-of-the-box feature that allows you to specify an administration theme from the Drupal administration pages.

<?php
/**
* This snippet tells Drupal to load up a different page-admin.tpl.php layout
* files automatically. For use in the template.php file.
*
* This works with and Drupal 4.7, Drupal 5.x
*/
function _phptemplate_variables($hook, $variables = array()) {
  switch (
$hook) {
    case
'page':
      if ((
arg(0) == 'admin')) {
       
$variables['template_file'] = 'page-admin';
      }
      break;
  }
  return
$variables;
}
?>

Add/Edit theme switcher

The following snippet switches the theme layout for both ADMIN and when a user is editing or creating new content. A simple example application might be to display some editing tips where the sidebars normally appear.

<?php
/**
* This snippet tells Drupal to load up a different page-admin.tpl.php layout
* files automatically for admin pages and add/edit pages.
* For use in the template.php file.
*
* This works with and Drupal 4.7, Drupal 5.x
*/
function _phptemplate_variables($hook, $variables = array()) {
  switch (
$hook) {
    case
'page':
      if ((
arg(0) == 'node' && arg(1) == 'add') ||  (arg(0) == 'node' && arg(2) == 'edit')) {
       
$variables['template_file'] = 'page-admin';
      }
      break;
  }
  return
$variables;
}
?>

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

I tried the second piece of code. Doesn't work in D6. page-node-edit.tpl doesn't change.

-----------------------------
Subir Ghosh
Newswatch
www.newswatch.in