Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: Theme Templates Order

Submitted by on August 16, 2011 – 8:54 amNo Comment

In this article we will figure out an order which is used for templates of your Drupal-based website. Read the full story to get know the details.

PHPTemplate supports using of templates for a certain system URLs.

If you are at http://example.com/node/1/edit, then templates will be found in the following sequence:

  • page-node-edit.tpl.php
  • page-node-1.tpl.php
  • page-node.tpl.php
  • page.tpl.php

If you are at http://example.com/tracker, then templates will be found in the following sequence:

  • page.tpl.php

If you are at http://example.com/user/1, then templates will be found in the following sequence:

  • page-user-1.tpl.php
  • page-user.tpl.php
  • page.tpl.php

If you are at http://example.com/taxonomy/term/1, then templates will be found in the following sequence:

  • page-taxonomy-term-1.tpl.php
  • page-taxonomy-term.tpl.php
  • page-taxonomy.tpl.php
  • page.tpl.php

If you are at http://example.com/, then templates will be found in the following sequence:

  • page-front.tpl.php
  • page.tpl.php

You can create templates to generate individual pages. Page templates could be based on the system URL of a page.

For example, if you are at  /node/1/edit, then templates will be found in the following order:

  • page-node-edit.tpl.php
  • page-node-1.tpl.php
  • page-node.tpl.php
  • page.tpl.php

Note: templates are found on the basis of standard Drupal URL. I.e. if you have set an alternative URL manually or you use Pathauto module, templates will be found regarding their system path anyway. Alternative URLs will not be used for the search.

If you want to switch page templates following a certain rules (for example, user roles), you should specify the rules in template.php. $vars[‘template_files’] variable should define array of possible templates.

You can view an example of defining templates with this variable here:
Creating a separate admin theme.

Good luck!

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.