Drupal's file template system: Hierarchy and Priority
Lately, I have been doing some tweaks to Drishtikone which may not have been apparent. Drupal follows a file system that where the nodes, pages, blocks etc follow a certain hierarchy and priority. Since I will be using this information, I wanted to lay it down in one place for future use:
For pages:
page-node-edit.tpl.php
page-node-1.tpl.php
page-node.tpl.php
page.tpl.php
Example: Your home page.
page-front.tpl.php
page.tpl.php
Tracker page:
page-tracker.tpl.php
page.tpl.php
For nodes:
node-type.tpl.php
node.tpl.php
For comments:
comment.tpl.php
For blocks:
block-module-delta.tpl.php
block-module.tpl.php
block-region.tpl.php
block.tpl.php
For boxes:
box.tpl.php
Taxonomy:
page-vocabularyname-termname1-termname2.tpl.php
page-vocabularyname-termname1.tpl.php
page-vocabularyname.tpl.php
Admin:
page-admin.tpl.php
Login:
page-login.tpl.php
comments from drupal.org page:
1. When determining which template file to use, it’ll start from the top and work its way down. So, for example, if node-type.tpl.php file doesn’t exist, it’ll use node.tpl.php. For a better look as to how templates work, take a look at the phptemplate.engine file in your themes/engines/phptemplate folder.
2. All the template naming suggestions are set from phptemplate.engine. Peek in that file and look for phptemplate_HOOK. In Drupal 5, there’s a callback function that accepts templates for the last parameter. Once you understand what it’s doing, you can go a lot further and change it to your liking with _phptemplate_variables() by passing $vars[‘template_files’] with an array of your own suggestions.
For additional discussion visit these pages: Using DIff Page Templates . Hierarchy of Templates