Drupal: sub themes overriding pages based on alias

If you have a theme (for example the lovely rubik admin theme) and you want to change the look and feel for just a few pages based on path aliases (so in my case I have a admin/content/workflow section which I want to have a specific heavily customised look and feel for), you can simply create a sub theme.

The first thing you need to is create your theme folder, .info file and template.php file. Inside your template.php file add a mythemename_preprocess_page containing the following:


if (module_exists('path')) {
$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
if ($alias == $_GET['q'] && $alias == 'admin/content/workflow') {
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '-' . $path_part;
$vars['template_files'][] = $template_filename . '-sanbi';
}
}
}

I would imagine it’s more efficient to customise this function specifically for the few cases you will be using. Any way, once you have a function like this (or similar), as you would imagine, you can create a page-your-customised-page-alias.tpl.php page inside your sub theme folder. However you must also create a page.tpl.php page to go in the same directory. The helpful hefox on #drupal irc.freenode.org pointed out that this page.tpl.php does not have to be copied from your base theme’s folder, but can actually just contain something like:


< ?php include_once('sites/all/themes/rubik/page.tpl.php'); ?>

Which is nice.