Drupal Template File

There are already have some Drupal core function let us using templates. As the following.  For Drupal 6, Drupal 6 Template Suggestions will help. If you want customise more flexible conditions, have a look on Working with template suggestions .

For Node:

Just use the following file name rules to template drupal:

  1. page.tpl.php (global)
  2. page-front.tpl.php (front page)
  3. page-node-edit.tpl.php (node edit)
  4. page-node-[#].tpl.php (specific node)
  5. page-node.tpl.php (nodes – global)
  6. page-[internal/path].tpl.php (specific path)
  7. page-node-[content type].tpl.php  (specific content type)

If not add the page prefix, like the following, then it will use page prefixed tpl file as their parent template( which already have layout including header and footer  )

  1. node.tpl.php
  2. node-[#].tpl.php
  3. node-[content type].tpl.php

For block:

take a look at this page: https://drupal.org/node/104319

Drupal 7

In Drupal 7 template files are searched in the following order:

  • block–block–[block-id].tpl.php
  • block–[module]–[delta].tpl.php
  • block–[module].tpl.php
  • block–[region].tpl.php
  • block.tpl.php

If the block delta key uses a hyphen, (-), replace this with an underscore (_).

Drupal 7 Template (Theme Hook) Suggestions

Drupal 5 & 6

In Drupal 5 and 6, template files are searched in the following order:

  • block-[module]-[delta].tpl.php
  • block-[module].tpl.php
  • block-[region].tpl.php
  • block.tpl.php

For example, the user login block has a delta of ‘0’. If you put it in the left sidebar, when it’s rendered, PHPTemplate will search for the following templates in descending order:

  • block-user-0.tpl.php
  • block-user.tpl.php
  • block-left.tpl.php
  • block.tpl.php

Leave a Reply