{ Allow Drupal Templates By Node ID }

By default, Drupal will let you define a template called node-bork.tpl.php, which is a template for all nodes of type “bork.” That’s pretty handy, but what if you want a template for a specific node id? What I want to be able to do is define a template called node-4.tpl.php, which would be the template for the node with node id 4. Here’s how.

 

In /includes/theme.inc there is a function template_preprocess_node. At the bottom is this line:

$variables[‘template_files’][] = ‘node-‘. $node->type;

Just add this line:

$variables[‘template_files’][] = ‘node-‘. $node->nid;

Leave a Reply

Your email address will not be published. Required fields are marked *