drupal variables in theme files

Theme variables available to all Drupal template files

$zebra
In the case of multiple renderings of a template in one request, this indicates if this is an odd or even invocation. The value is odd or even. Perfect for generating stuff like zebra tables etc.
$id
In the case of multiple renderings of a template in one request, this indicates which rendering this is (1st, 2nd, …).
$directory
The path of the theme directory. Same as path_to_theme. Example:sites/all/themes/my_theme
$is_admin
Indicates if the user has the access administration pages permission set (user_access('access administration pages'))
$is_front
Indicates if the current request is the front page (drupal_is_front_page()).
$logged_in
Indicates if the current user is logged in.
$user
Contains the user object of the current user.

(Thanks to drupalcoder)

block.tpl.php

Available variables:

  • $block->subject: Block title.
  • $block->content: Block content.
  • $block->module: Module that generated the block.
  • $block->delta: This is a numeric id connected to each module.
  • $block->region: The block region embedding the current block.

Helper variables:

  • $block_zebra: Outputs ‘odd’ and ‘even’ dependent on each block region.
  • $zebra: Same output as $block_zebra but independent of any block region.
  • $block_id: Counter dependent on each block region.
  • $id: Same output as $block_id but independent of any block region.
  • $is_front: Flags true when presented in the front page.
  • $logged_in: Flags true when the current user is a logged-in member.
  • $is_admin: Flags true when the current user is an administrator.

http://api.drupal.org/api/drupal/modules–system–block.tpl.php/6

node.tpl.php

Available variables:

  • $title: the (sanitized) title of the node.
  • $content: Node body or teaser depending on $teaser flag.
  • $picture: The authors picture of the node output from theme_user_picture().
  • $date: Formatted creation date (use $created to reformat with format_date()).
  • $links: Themed links like “Read more”, “Add new comment”, etc. output from theme_links().
  • $name: Themed username of node author output from theme_username().
  • $node_url: Direct url of the current node.
  • $terms: the themed list of taxonomy term links output from theme_links().
  • $submitted: themed submission information output from theme_node_submitted().

Other variables:

  • $node: Full node object. Contains data that may not be safe.
  • $type: Node type, i.e. story, page, blog, etc.
  • $comment_count: Number of comments attached to the node.
  • $uid: User ID of the node author.
  • $created: Time the node was published formatted in Unix timestamp.
  • $zebra: Outputs either “even” or “odd”. Useful for zebra striping in teaser listings.
  • $id: Position of the node. Increments each time it’s output.

Node status variables:

  • $teaser: Flag for the teaser state.
  • $page: Flag for the full page state.
  • $promote: Flag for front page promotion state.
  • $sticky: Flags for sticky post setting.
  • $status: Flag for published status.
  • $comment: State of comment settings for the node.
  • $readmore: Flags true if the teaser content of the node cannot hold the main body content.
  • $is_front: Flags true when presented in the front page.
  • $logged_in: Flags true when the current user is a logged-in member.
  • $is_admin: Flags true when the current user is an administrator.

http://api.drupal.org/api/drupal/modules–node–node.tpl.php/6

Reply