Blog Image

Create template specific to node in drupal 6

If you want to have custom templates for your node. You can create templates specific to node ID as follows.

Add the below function in your template.php if its not exists.

function yourcurrentthemename_preprocess_node(&$vars, $hook) {
$node = $vars[‘node’];
$vars[‘template_file’] = ‘node-‘. $node->nid;
}

If the function already exists then add the two lines at the beginning of the function.

Then clear the cache.

So if you want to have a custom template for node id 3 (say for example) then create a template with name node-3.tpl.php in your theme directory.

Now you can customise your template as you need.

Keep Rocking…..Enjoy 🙂



Author: admin

Vinod Ram has been in Software Industry since 2006 and has experience of over 16 years in Software Development & Project Management domain specialised majorly in LAMP stack & Open Source Technology, building enterprise level Web based Application, Large Database driven and huge traffic Websites and Project Management. He loves to write information articles and blog to share his knowledge and experience with the outside world and help people to find solution for their problems.