This template controls the display of a node, and a node summary. It can only affect the output of the $content variable.

Available variables

Node content, teaser if it is a summary.
Formatted creation date.
The directory the theme is located in, e.g. themes/garland or themes/garland/minelli.
The sequential ID of the node being displayed in a list.
True if the front page is currently being displayed.
Node links.
$main (4.6)
True if the node is appearing in a context, like the front page, where only the teaser should be shown. No longer used in 4.7 and later.
Formatted name of author.
$node (object)
The node object. To view all of the properties of a current $node object, put the following line of code in your node.tpl.php: <pre><?php print_r($node); ?></pre>
Link to node.
True if the node is being displayed by itself as a page.
HTML for user picture, if enabled.
True if the node is sticky.


Lays out content for blocks (left and/or right side of page). This template is optional, and can be overridden by copying the default template and modifying it.

For Drupal 6 block templating information, see:

Available variables

The $block object includes:

The name of the module that generated the block.
The number of the block for a particular module.
The block title.
The html content for the block.
Status of block (0 or 1).
Region name, by default the available regions are 'left', 'right', 'header' and 'footer'.
Throttle setting.

Other variables:

The directory the theme is located in, e.g. themes/garland or themes/garland/minelli.
True if the front page is currently being displayed.
The sequential id of the block displayed, ie: The first block is 1, the second block is 2 etc.
The same as $id, but is reset for the left and right sidebars.
Alternates between 'odd' and 'even'. This is useful for creating 'zebra stripes' with your css.

ARCHIVE: template.php: Overriding other theme functions

If you want to override a theme function not included in the basic list (block, box, comment, node, page), you need to tell PHPTemplate about it.

To do this, you need to create a template.php file in your theme's directory. This file must start with a PHP opening tag <?php but the close tag is not needed and it is recommended that you omit it. Also included in the file are stubs for the theme overrides. These stubs instruct the engine what template file to use and which variables to pass to it.

First, you need to locate the appropriate theme function to override. You can find a list of these in the API documentation. We will use theme_item_list() as an example.

The function definition for theme_item_list() looks like this:

<?php function theme_item_list($items = array(), $title = NULL) {
$output = '<div class="item-list">';
  if (isset(
$title)) {
$output .= '<h3>'. $title .'</h3>';

Now you need to place a stub in your theme's template.php, like this:
* Catch the theme_item_list function, and redirect through the template api
function phptemplate_item_list($items = array(), $title = NULL) {

Theming overview

A few handbook pages has been moved to the new theming handbook. A fresh start for Drupal 6 and beyond. This handbook will eventually be part of a sub-section of the new outline after it has been cleansed out. The theme upgrade guide has been moved too.

Note: this page describes the theme system from a themer's perspective. If you are a module coder looking to make your module themable, you should read this page.

Creating a screenshot for the administration page

Note: There is a separate page on this for Drupal 7:

Every theme for 4.5+ needs a screenshot in the form of a screenshot.png placed in the theme directory. These are displayed in the theme listing within a Drupal installation (i.e. at Administer > Site building > Themes in Drupal 5 or 6). It is best that screenshots are consistent. The guidelines for core theme screenshots are (starting from a blank Drupal site):

  1. Log in as the first user.
  2. Enable the following modules, for some extra menu items: aggregator, blog, node, search and tracker.
  3. Turn on the features that the theme supports (logo, site name, slogan, search box). Add some primary and secondary links if needed. We suggest "Link 1" "Link 2" "Link 3", you can link them to e.g. "user/1".
  4. Set the site name to Drupal and slogan to Community Plumbing.
  5. Create the following article node:

    Donec felis eros, blandit non


Subscribe with RSS Subscribe to RSS - Drupal 4.7.x