Skip to content Skip to navigation

Creating a Page Template Suggestion for a Specific Node Type in Drupal 7

« previous next »

Add the following function to the template.php for your theme:

function yourthemename_preprocess_page(&$vars, $hook) {
 if (isset($vars['node'])) {
 // If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
  $vars['theme_hook_suggestions'][] = 'page__'.$vars['node']->type;
 }
}

 
Change the "yourthemename" in the function name to match the name of your theme.