Do you want to override template.php in Drupal, say to produce a custom administration theme? If so, boy do I have a treat for you. This technique involves using the '_phptemplate_variables()' function. Say, for example, you have created a new template page named 'page-admin.tpl.php'. You want pages who's URL ends in '/admin', '/tracker', '/node/add', '/node/edit' and any sub paths from those to use the new template page. The following code would accomplish your mission:
function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'page':
if ((arg(0) == 'admin') ||
(arg(0) == 'tracker') ||
(arg(0) == 'node' && arg(1) == 'add') ||
(arg(0) == 'node' && arg(2) == 'edit')) {
$vars['template_file'] = 'page-admin';
}
break;
}
return $vars;
}
And voila, all your admin pages will inherit their layout from page-admin.tpl.php.
If you found this useful, please leave a quick comment, thanks!