This document provides a summary of template variables available in different Drupal templates like page.tpl.php, node.tpl.php, and comment.tpl.php. It lists general utility variables, site identity variables, navigation variables, and node-specific variables that can be used to display content, metadata, and information about the author for each template. The template variables allow templates to access important data about the page, node, or comment being displayed to output dynamic content.
This document provides a summary of template variables available in different Drupal templates like page.tpl.php, node.tpl.php, and comment.tpl.php. It lists general utility variables, site identity variables, navigation variables, and node-specific variables that can be used to display content, metadata, and information about the author for each template. The template variables allow templates to access important data about the page, node, or comment being displayed to output dynamic content.
General Utility Variables Available Variables $base_path The base URL path of the Drupal installation. $title The title of the node. $directory The directory the template is located $content An array of node items. Use render($content) to print $is_front TRUE if the current page is the front page. them all, or print a subset such as render($content[‘field_ example’]). Use hide($content[‘field_example’]) to tempo- $logged_in TRUE if the user is registered and signed in. rarily suppress the printing of a given element. $is_admin TRUE if the user has permission to access administration $user_picture The node author’s picture from user-picture.tpl.php. pages. $date Formatted creation date Site Identity $name Themed username of node author output from theme_ $front_page The URL of the front page. username(). $logo The path to the logo image $terms the themed list of taxonomy term links output from $site_name The name of the site theme_links(). $site_slogan The slogan of the site $node_url Direct url of the current node. $highlight Replace of a $mission $display_submitted Whether submission information should be displayed. $title_prefix An array containing additional output populated by mod- $submitted Submission information created from $name and $date ules during $title The page title $classes String of classes that can be used to style contextually $title_suffix An array containing additional output populated by mod- through CSS ules $title_prefix An array containing additional output populated by $messages HTML for status and error messages modules $tabs Tabs linking to any sub-pages beneath the current page $title_suffix An array containing additional output populated by modules $action_links Actions local to the page Other variables $feed_icons A string of all feed icons for the current page. $node Full node object $node The node object $type Node type Navigation $comment_count Number of comments attached to the node. $main_menu An array containing the Main menu links for the $uid User ID of the node author. site, if they have been configured. $created Time the node was published formatted in Unix times- $secondary_menu An array containing the Secondary menu links for tamp. the site, if they have been configured. $classes_array Array of html class attribute values. $breadcrumb: The breadcrumb trail for the current page. $zebra Outputs either “even” or “odd”. html.tpl.php variables $id Position of the node. Increments each time it’s output. $css An array of CSS files for the current page. $terms Outputs taxonomy terms associated to nodes $language The language the site is being displayed in. Node Status $language->dir contains the language direction. It will either be ‘ltr’ or ‘rtl’. $view_mode View mode, e.g. ‘full’, ‘teaser’. $language->language contains its textual representation. $teaser Flag for the teaser state (shortcut for $view_mode == $head_title A modified version of the page title, for use in the TITLE tag. ‘teaser’) $head_title_array An associative array containing $page: Flag for the full page state. title : The title of the current page, if any. $promote lag for front page promotion state. name: The name of the site. $sticky Flags for sticky post setting. slogan: The slogan of the site, if any, and if there is no title. $status Flag for published status. $head Markup for the HEAD section (including meta tags, keyword tags, and so on). $comment State of comment settings for the node. $styles Style tags necessary to import all CSS files for the page $readmore Flags true if the teaser content of the node cannot hold the main body content. $scripts Script tags necessary to load the JavaScript files and settings for the page. $is_front: Flags true when presented in the front page. $page_top Initial markup from any modules that have altered the page. $logged_in Flags true when the current user is a logged-in member. This variable should $is_admin Flags true when the current user is an administrator. $page The rendered page content. comment.tpl.php variables $page_bottom Final closing markup from any modules that have altered $author Comment author the page. This variable should always be output last, after all $content An array of comment items. Use render($content) to print other dynamic content. them all, or print a subset such as render($content[‘field_ $classes String of classes that can be used to style contextually example’]). through CSS. $created Formatted date and time for when the comment was cre- block.tpl.php variables ated Available Variables $changed Formatted date and time for when the comment was last $title Block title changed. $content Block content. $new New comment marker. $block->module Module that generated the block. $permalink Comment permalink. $block->delta An ID for the block $submitted Submission information created from $author and $cre- ated $block->region The block region embedding the current block $picture Authors picture. $classes String of classes that can be used to style contextually through CSS $signature Authors signature. $title_prefix An array containing additional output $status Comment status $title_suffix An array containing additional output $title Linked title. Helper Variables $classes tring of classes that can be used to style contextually through CSS. $classes_array Array of html class attribute values $title_prefix An array containing additional output populated by $block_zebra Outputs ‘odd’ and ‘even’ dependent on each block region. modules $zebra Same output as $block_zebra but independent of any block $title_suffix An array containing additional output populated by region. modules $block_id Counter dependent on each block region. These two variables are provided for context $id Same output as $block_id but independent of any block $comment Full comment object. region. $node Node object the comments are attached to. $is_front Flags true when presented in the front page
$logged_in lags true when the current user is a logged-in member.
$is_admin Flags true when the current user is an administrator. $block_html_id A valid HTML ID and guaranteed unique. Template files [themename].info Meta data, style sheets, JavaScripts, block regions html.tpl.php Page wrapper for your theme. Here you have the DOCTYPE declaration, the <head> info, and page closer. page,tpl.php Default theme implementation to display a single Drupal page. v region.tpl.php Default theme implementation to display a region. block.tpl.php Default theme implementation to display a block. node.tpl.php Default theme implementation to display a node. node--[content-type].tpl.php Template for displaying a node of a specific content type. page--front.tpl.php Default theme implementation to display a custom frontpage node--blog.tpl.php Default theme implementation to display a node of type blog page--node-[#].tpl.php Theme implementation to display page with node ID # block--[region].tpl.php Theme implementation for block in region name html.tpl.php code $header <head profile=”<?php print $grddl_profile; ?>”> <?php print $head; ?> <title><?php print $head_title; ?></title> <?php print $styles; ?> <?php print $scripts; ?> </head> body <body class=”<?php print $classes; ?>” <?php print $attributes;?>> <div id=”skip-link”> <a href=”#main-menu”><?php print t(‘Jump to Navigation’); ?></a> </div> <?php print $page_top; ?> <?php print $page; ?> <?php print $page_bottom; ?> </body> Logo <?php if ($logo): ?> <a href=”<?php print $front_page; ?>” title=”<?php print t(‘Home’); ?>” rel=”home” id=”logo”><img src=”<?php print $logo; ?>” alt=”<?php print t(‘Home’); ?>” /></a> <?php endif; ?> Site Name <?php if ($site_name): ?> <?php if ($title): ?> <div id=”site-name”><strong> <a href=”<?php print $front_page; ?>” title=”<?php print t(‘Home’); ?>” rel=”home”><span><?php print $site_name; ?></span></a> </strong></div> <?php else: ?> <h1 id=”site-name”> <a href=”<?php print $front_page; ?>” title=”<?php print t(‘Home’); ?>” rel=”home”><span><?php print $site_name; ?></span></a> </h1> <?php endif; ?> <?php endif; ?> Site Slogan <?php if ($site_slogan): ?> <div id=”site-slogan”><?php print $site_slogan; ?></div> <?php endif; ?> Header <?php print render($page[‘header’]); ?> Highlight <?php print render($page[‘highlight’]); ?> Breadcrum <?php print $breadcrumb; ?> Title Prefix <?php print render($title_prefix); ?> Page Title <h1 class=”title” id=”page-title”><?php print $title; ?></h1> Title Suffix <?php print render($title_suffix); ?> Messages <?php print $messages; ?> Tabs <?php print render($tabs); ?> Help <?php print render($page[‘help’]); ?> Content <?php print render($page[‘content’]); ?> Action Links <ul class=”action-links”><?php print render($action_links); ?></ul> Main Menu <?php print theme(‘links__system_main_menu’, array( ‘links’ => $main_menu, ‘attributes’ => array( ‘id’ => ‘main-menu’, ‘class’ => array(‘links’, ‘clearfix’), ), ‘heading’ => array( ‘text’ => t(‘Main menu’), ‘level’ => ‘h2’, ‘class’ => array(‘element-invisible’), ),)); ?> Secondary Menu <?php print theme(‘links__system_secondary_menu’, array( ‘links’ => $secondary_menu, ‘attributes’ => array( ‘id’ => ‘secondary-menu’, ‘class’ => array(‘links’, ‘clearfix’), ), ‘heading’ => array( ‘text’ => t(‘Secondary menu’), ‘level’ => ‘h2’, ‘class’ => array(‘element-invisible’), ),)); ?>