SlideShare a Scribd company logo
Drupal 7 phptemplate cheatsheet
                                page.tpl.php variables                                                                           node.tpl.php variables
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’),
                                 ),)); ?>

Navigation                    <?php print render($page[‘navigation’]); ?>
Sidebar Region                <?php print render($page[‘sidebar_first’]); ?>
Footer                        <?php print render($page[‘footer’]); ?>

                                                           Done by Alaa Batayneh | http://batayneh.me | February 2011 | Inspiration by wikikiwis

More Related Content

PDF
Cake php 1.2-cheatsheet
DOCX
List of all php array functions
PDF
Cheatsheet
KEY
Building a Pluggable Plugin
PPTX
Mastering Custom Post Types - WordCamp Atlanta 2012
PDF
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
PDF
DataMapper
PDF
Cake php 1.2-cheatsheet
List of all php array functions
Cheatsheet
Building a Pluggable Plugin
Mastering Custom Post Types - WordCamp Atlanta 2012
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
DataMapper

What's hot (20)

PDF
PDF
Drupal is Stupid (But I Love It Anyway)
PPTX
RESTful APIs: Promises & lies
PDF
Doctrator Symfony Live 2011 San Francisco
PDF
Migrate
PDF
Drupal 8: Forms
PDF
Datamapper Railskonferenz 2009
PDF
Dig Deeper into WordPress - WD Meetup Cairo
PPTX
Views notwithstanding
KEY
The Query the Whole Query and Nothing but the Query
PDF
Dependency injection - phpday 2010
PDF
Drupal 8: Routing & More
KEY
Dm adapter RubyConf.TW
PDF
Transparent Object Persistence with FLOW3
KEY
Theme API
PDF
Dependency injection-zendcon-2010
PDF
Dependency injection in PHP 5.3/5.4
KEY
PDF
Transparent Object Persistence with FLOW3
ODP
Entity Query API
Drupal is Stupid (But I Love It Anyway)
RESTful APIs: Promises & lies
Doctrator Symfony Live 2011 San Francisco
Migrate
Drupal 8: Forms
Datamapper Railskonferenz 2009
Dig Deeper into WordPress - WD Meetup Cairo
Views notwithstanding
The Query the Whole Query and Nothing but the Query
Dependency injection - phpday 2010
Drupal 8: Routing & More
Dm adapter RubyConf.TW
Transparent Object Persistence with FLOW3
Theme API
Dependency injection-zendcon-2010
Dependency injection in PHP 5.3/5.4
Transparent Object Persistence with FLOW3
Entity Query API
Ad

Similar to Drupal7 theming-cheatsheet 0 (9)

PDF
Doctrine MongoDB Object Document Mapper
PDF
Drupal 8: Entities
PDF
Drupal 7 Theming - Behind the scenes
DOC
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
PDF
Doctrine 2
PDF
Symfony Admin Generator
KEY
Zf Zend Db by aida
PPTX
Drupal II: The SQL
PPTX
Drupal Camp Porto - Developing with Drupal: First Steps
Doctrine MongoDB Object Document Mapper
Drupal 8: Entities
Drupal 7 Theming - Behind the scenes
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
Doctrine 2
Symfony Admin Generator
Zf Zend Db by aida
Drupal II: The SQL
Drupal Camp Porto - Developing with Drupal: First Steps
Ad

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Spectroscopy.pptx food analysis technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Big Data Technologies - Introduction.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
sap open course for s4hana steps from ECC to s4
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Spectroscopy.pptx food analysis technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Review of recent advances in non-invasive hemoglobin estimation
Big Data Technologies - Introduction.pptx
Spectral efficient network and resource selection model in 5G networks
MIND Revenue Release Quarter 2 2025 Press Release
Mobile App Security Testing_ A Comprehensive Guide.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
NewMind AI Weekly Chronicles - August'25-Week II
Chapter 3 Spatial Domain Image Processing.pdf
Network Security Unit 5.pdf for BCA BBA.
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Dropbox Q2 2025 Financial Results & Investor Presentation

Drupal7 theming-cheatsheet 0

  • 1. Drupal 7 phptemplate cheatsheet page.tpl.php variables node.tpl.php variables 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.
  • 2. 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’), ),)); ?> Navigation <?php print render($page[‘navigation’]); ?> Sidebar Region <?php print render($page[‘sidebar_first’]); ?> Footer <?php print render($page[‘footer’]); ?> Done by Alaa Batayneh | http://batayneh.me | February 2011 | Inspiration by wikikiwis