theming just one node in drupal

Drupal’s theming system uses file names to decide which theme to apply to whatever page the visitor is asking for. So  page-front.tpl.php is the front page, block-footer.tpl.php is any block in the footer, page-node-10.tpl is the page that contains node 10, etc etc

However, out of the box, there is no way to theme just one node. You can’t go node-1.tpl.php and expect node 1 to be themed. To get around this, add the following to your theme’s template.php

function phptemplate_preprocess_node(&$vars, $hook) {
  $node = $vars['node'];
  $vars['template_file'] = 'node-'. $node->nid;

Then visit the /admin/build/modules/list so that Drupal’s cache of template.php is refreshed.

Leave a Reply

Your email address will not be published.