Skip to Navigation

Drupal: Customize Entire Page Template Based On Content Type

I have a couple of projects that call for node content to be published outside of the normal center-of-the-page boundary. But the default template override system accounts for individual nodes, or even overriding the node display area for a given content type, but not the whole page. A Google search turned up some possibilities, but based on this page, I was able to find the right answer for Drupal 5.x, in templates.php:

    1 <?php
    2 function phptemplate_variables($hook, $vars = array())
    3 {
    5     switch ($hook)
    6     {
    7         case 'page':
    9             if ('node' == arg(0))
   10             {
   11                 $vars['template_files'] = 'page' . $vars['node']->type;
   12             }
   14          break;
   15      }
   17      return $vars;
   18 }
   20 ?>

This means if you have a content type called event and you want it to have a custom page layout, just copy page.tpl.php to page_event.tpl.php. Dunno why this isn't part of the default theme system, but maybe it's an un-Drupal thing to want to do.

EDIT:Floyd in the comments points to a nice improvement he made on this technique.