Separate node template for a specific node
Last modified: August 26, 2009 - 20:43
If you want to use a specific node.tpl.php for a particular node, paste or merge this code into your template.php:
Drupal 6
<?php
function phptemplate_preprocess_node(&$vars) {
$vars['template_files'][] = 'node-' . $vars['nid'];
return $vars;
}
?>Drupal 4.7.x and Drupal 5.x
<?php
function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'node':
$vars['template_files'] = array('node-'. $vars['nid']);
break;
}
return $vars;
}
?>You can now use the template naming convention node-[nid].tpl.php such as node-34.tpl.php to create a custom node template for just the node 34.
Note that Drupal 7 out-of-the-box looks for node-specific templates, so you don't need to do anything to template.php.
