Skip to content

Instantly share code, notes, and snippets.

@resting
Created November 26, 2010 02:50
Show Gist options
  • Save resting/716214 to your computer and use it in GitHub Desktop.
Save resting/716214 to your computer and use it in GitHub Desktop.
Drupal page template on nodetype
/**
* Override or insert PHPTemplate variables into the templates.
*/
function _phptemplate_variables($hook, $vars) {
if ($hook == 'page') {
// Add page template suggestions based on node type, if we aren't editing the node.
if ($vars['node'] && arg(2) != 'edit') {
$vars['template_files'][] = 'page-nodetype-'. $vars['node']->type;
}
if ($secondary = menu_secondary_local_tasks()) {
$output = '<span class="clear"></span>';
$output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
$vars['tabs2'] = $output;
}
// Hook into color.module
if (module_exists('color')) {
_color_page_alter($vars);
}
return $vars;
}
return array();
}
@resting
Copy link
Author

resting commented Nov 26, 2010

The only important part...
// Add page template suggestions based on node type, if we aren't editing the node.
if ($vars['node'] && arg(2) != 'edit') {
$vars['template_files'][] = 'page-nodetype-'. $vars['node']->type;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment