0
votes

I have 3 nodes in my sites.

  1. node/1 - Login
  2. node/2 - Contact
  3. node/3 - Register

I want to have different template for different nodes. If I do as page-node-1.tpl.php , page-node-2-tpl.php , its for the entire page, I don't want that, I want specifically override for node content.

I have already tried the following links:-

I am using Drupal 6

1
Ayesh is right. Just don't forget to clear the cache after you add new template file!MilanG

1 Answers

0
votes

I have not used Drupal 6 in a while, but from what I realized, Drupal 6's default node templates will not have a node ID based template suggestion.

That does not mean you cannot do it from a custom theme.

<?php

function THEMENAME_preprocess_node(&$vars) {
    $vars['template_files'][] = 'node-' . $vars['nid'];
}

?>

In your theme's template.php, add the above code, replacing the theme name (or merge the function contents if you already have that function). This will make the Drupal check for node-123.tpl.php file (123 being an example node ID), and will use it for in place of node.tpl.php.

Since you mentioned you'd be using node/1 or any node contents to embed a login form, let me tell you that this isn't exactly a good idea. The login form needs to be accessible when the site is in maintenance mode, and it can be hard to manage them later with different deployment environments. This part is completely irrelevant to the question though.