I am using the following code.

function chgakitheme_preprocess_page(&$vars, $hook) {
  if ($vars['user']->uid == 0 && arg(0) == 'user' && (arg(1) == '' || arg(1) == 'login')) {
    array_unshift($vars['template_files'], 'page-login');
    $vars['body_classes'] .= ' userlogin';

  if (isset($vars['node'])) {
   $vars['template_files'][] = 'page-'. str_replace('_', '-', $vars['node']->type);

Now I can use page-nodetype.tpl.php, but I can't use page-node-nid.tpl.php because Drupal doesn't see it.

I need all types of template files. I want a template specific for a content type.

What can I do? Can I do this in Drupal 6?

1 Answer 1


Have a look at the Drupal 6 Template suggestions, The list of suggested template files is in order of specificity based on internal paths. One suggestion is made for every element of the current path, though numeric elements are not carried to subsequent suggestion, order of execution is as below:

  • page-node-edit.tpl.php
  • page-node-[node_id].tpl.php
  • page-node.tpl.php
  • page.tpl.php

So basically you don't need to use the "TEMPLATE_preprocess_page" for using "page-node-[node_id].tpl.php" for template suggestion as it is provided by default. May be the problem is of "clearing the cache", try once after clearing the cache.

In Drupal6, page-node-[node_type].tpl.php is not available by default, to make it work we customize the suggestions in the TEMPLATE_preprocess_page as done by you.

If you want more specific templates than you can customize the template suggestions as your requirement in TEMPLATE_preprocess_page. Example as below:

// Implement TEMPLATE_preprocess_page.
function TEMPLATE_preprocess_page(&$variables) {
  if ($variables['node']->type !== '') {
    // For using "page-node-[node_type].tpl.php" for template suggestion.
    $variables['template_files'][] = "page-node-" . $variables['node']->type;

    // For using "page-node-[node_type]-[node_id].tpl.php" for template suggestion.
    $variables['template_files'][] = "page-node-" . $variables['node']->type . "-" . $variables['node']->nid;

After using the above code you can use the additional template suggestion as below:

  • page-node-[node_type]-[node_id].tpl.php
  • page-node-[node_type].tpl.php

NOTE: Don't forget to clear the cache after making changes to template files otherwise the changes won't reflect back.

  • page-node-[node_type]-[node_id].tpl.php is work, but page-node-[node_type].tpl.php in not work Oct 19, 2013 at 16:49
  • Important: if i use MYTHEMENAME_preprocess_page - work page-node-[node_type]-[node_id].tpl.php, in i use PHPTHEMPLATE_preprocess_page - work page-node-[node_type].tpl.php. If i use first and second - don't work page-node-[node_type]-[node_id].tpl.php Oct 19, 2013 at 16:52
  • Sorry - this is work! But need: PHPTEMPLATE_preprocess_page Oct 19, 2013 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.