Themes and templates are placed in their own subdirectory in the themes directory.
The default theme for Drupal 5.x is garland, just copy it to a new directory in themes, and give it a unique name.
The Important Files
logo.png : logo
style.css: element styles
page.tpl.php : theme a page
block.tpl.php : theme a block in sidebar
box.tpl.php : theme a generic container for the main area
comment.tpl.php : theme a comment
node.tpl.php : theme a node
Theming specific node(content) types
To theme individual content types in different ways, you need to create a file node-$type.tpl.php, where $type is the name of the content type, for each type you wish to theme. Some examples:
node-story.tpl.php would theme only story nodes.
node-page.tpl.php would theme only page nodes. (Note that this is different from page.tpl.php which controls the layout of the entire page including header, sidebars, etc)
node-forum.tpl.php would theme only forum nodes.
node-book.tpl.php would theme only book nodes.
Using different block templates for different blocks, regions
In Drupal 5.0, designers can create multiple tpl.php files for blocks based on the specific block, the module that created the block, or the region that the block appears in.
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
Using different page templates depending on the current path
In Drupal 5.0, PHPTemplate supports the use of multiple page templates for a single theme. Depending on the current url path (node/1, taxonomy/term/2, or user/1, for example), PHPTemplate will search for multiple templates before falling back on the default page.tpl.php file.
For example, if you were to visit http://www.example.com/node/1/edit, PHPtemplate would look for the following templates, in descending order:
page-node-edit.tpl.php
page-node-1.tpl.php
page-node.tpl.php
page.tpl.php
If you were to visit http://www.example.com/tracker, PHPTemplate would look for the following templates:
page-tracker.tpl.php
page.tpl.php
Remember that these template suggestions are based on the default drupal path for a particular page. If you’ve used the path or pathauto module to hide them with url aliases, these templates will still be searched based on the original paths.
If you need to switch page template files based on some other rule (the role of the logged in user, for example), implement the phptemplate_variables() function in your theme’s template.php file. The ’suggestions’ variable should store an array of possible tpl.php files.














Post new comment