page.tpl.php

  1. 7.x drupal-7.x/modules/system/page.tpl.php
  2. 7.x drupal-7.x/themes/seven/page.tpl.php
  3. 7.x drupal-7.x/themes/garland/page.tpl.php
  4. 7.x drupal-7.x/themes/bartik/templates/page.tpl.php
  5. 7.x drupal-7.x/modules/block/tests/themes/block_test_theme/page.tpl.php
  6. 6.x drupal-6.x/modules/system/page.tpl.php
  7. 6.x drupal-6.x/themes/bluemarine/page.tpl.php
  8. 6.x drupal-6.x/themes/pushbutton/page.tpl.php
  9. 6.x drupal-6.x/themes/garland/page.tpl.php

Bartik's theme implementation to display a single Drupal page.

The doctype, html, head and body tags are not in this template. Instead they can be found in the html.tpl.php template normally located in the modules/system directory.

Available variables:

General utility variables:

  • $base_path: The base URL path of the Drupal installation. At the very least, this will always default to /.
  • $directory: The directory the template is located in, e.g. modules/system or themes/bartik.
  • $is_front: TRUE if the current page is the front page.
  • $logged_in: TRUE if the user is registered and signed in.
  • $is_admin: TRUE if the user has permission to access administration pages.

Site identity:

  • $front_page: The URL of the front page. Use this instead of $base_path, when linking to the front page. This includes the language domain or prefix.
  • $logo: The path to the logo image, as defined in theme configuration.
  • $site_name: The name of the site, empty when display has been disabled in theme settings.
  • $site_slogan: The slogan of the site, empty when display has been disabled in theme settings.
  • $hide_site_name: TRUE if the site name has been toggled off on the theme settings page. If hidden, the "element-invisible" class is added to make the site name visually hidden, but still accessible.
  • $hide_site_slogan: TRUE if the site slogan has been toggled off on the theme settings page. If hidden, the "element-invisible" class is added to make the site slogan visually hidden, but still accessible.

Navigation:

  • $main_menu (array): An array containing the Main menu links for the site, if they have been configured.
  • $secondary_menu (array): An array containing the Secondary menu links for the site, if they have been configured.
  • $breadcrumb: The breadcrumb trail for the current page.

Page content (in order of occurrence in the default page.tpl.php):

  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title: The page title, for use in the actual HTML content.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.
  • $messages: HTML for status and error messages. Should be displayed prominently.
  • $tabs (array): Tabs linking to any sub-pages beneath the current page (e.g., the view and edit tabs when displaying a node).
  • $action_links (array): Actions local to the page, such as 'Add menu' on the menu administration interface.
  • $feed_icons: A string of all feed icons for the current page.
  • $node: The node object, if there is an automatically-loaded node associated with the page, and the node ID is the second argument in the page's path (e.g. node/12345 and node/12345/revisions, but not comment/reply/12345).

Regions:

  • $page['header']: Items for the header region.
  • $page['featured']: Items for the featured region.
  • $page['highlighted']: Items for the highlighted content region.
  • $page['help']: Dynamic help text, mostly for admin pages.
  • $page['content']: The main content of the current page.
  • $page['sidebar_first']: Items for the first sidebar.
  • $page['triptych_first']: Items for the first triptych.
  • $page['triptych_middle']: Items for the middle triptych.
  • $page['triptych_last']: Items for the last triptych.
  • $page['footer_firstcolumn']: Items for the first footer column.
  • $page['footer_secondcolumn']: Items for the second footer column.
  • $page['footer_thirdcolumn']: Items for the third footer column.
  • $page['footer_fourthcolumn']: Items for the fourth footer column.
  • $page['footer']: Items for the footer region.

See also

template_preprocess()

template_preprocess_page()

template_process()

bartik_process_page()

html.tpl.php

1 theme call to page.tpl.php
system_element_info in drupal-7.x/modules/system/system.module
Implements hook_element_info().

File

drupal-7.x/themes/bartik/templates/page.tpl.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Bartik's theme implementation to display a single Drupal page.
  5. *
  6. * The doctype, html, head and body tags are not in this template. Instead they
  7. * can be found in the html.tpl.php template normally located in the
  8. * modules/system directory.
  9. *
  10. * Available variables:
  11. *
  12. * General utility variables:
  13. * - $base_path: The base URL path of the Drupal installation. At the very
  14. * least, this will always default to /.
  15. * - $directory: The directory the template is located in, e.g. modules/system
  16. * or themes/bartik.
  17. * - $is_front: TRUE if the current page is the front page.
  18. * - $logged_in: TRUE if the user is registered and signed in.
  19. * - $is_admin: TRUE if the user has permission to access administration pages.
  20. *
  21. * Site identity:
  22. * - $front_page: The URL of the front page. Use this instead of $base_path,
  23. * when linking to the front page. This includes the language domain or
  24. * prefix.
  25. * - $logo: The path to the logo image, as defined in theme configuration.
  26. * - $site_name: The name of the site, empty when display has been disabled
  27. * in theme settings.
  28. * - $site_slogan: The slogan of the site, empty when display has been disabled
  29. * in theme settings.
  30. * - $hide_site_name: TRUE if the site name has been toggled off on the theme
  31. * settings page. If hidden, the "element-invisible" class is added to make
  32. * the site name visually hidden, but still accessible.
  33. * - $hide_site_slogan: TRUE if the site slogan has been toggled off on the
  34. * theme settings page. If hidden, the "element-invisible" class is added to
  35. * make the site slogan visually hidden, but still accessible.
  36. *
  37. * Navigation:
  38. * - $main_menu (array): An array containing the Main menu links for the
  39. * site, if they have been configured.
  40. * - $secondary_menu (array): An array containing the Secondary menu links for
  41. * the site, if they have been configured.
  42. * - $breadcrumb: The breadcrumb trail for the current page.
  43. *
  44. * Page content (in order of occurrence in the default page.tpl.php):
  45. * - $title_prefix (array): An array containing additional output populated by
  46. * modules, intended to be displayed in front of the main title tag that
  47. * appears in the template.
  48. * - $title: The page title, for use in the actual HTML content.
  49. * - $title_suffix (array): An array containing additional output populated by
  50. * modules, intended to be displayed after the main title tag that appears in
  51. * the template.
  52. * - $messages: HTML for status and error messages. Should be displayed
  53. * prominently.
  54. * - $tabs (array): Tabs linking to any sub-pages beneath the current page
  55. * (e.g., the view and edit tabs when displaying a node).
  56. * - $action_links (array): Actions local to the page, such as 'Add menu' on the
  57. * menu administration interface.
  58. * - $feed_icons: A string of all feed icons for the current page.
  59. * - $node: The node object, if there is an automatically-loaded node
  60. * associated with the page, and the node ID is the second argument
  61. * in the page's path (e.g. node/12345 and node/12345/revisions, but not
  62. * comment/reply/12345).
  63. *
  64. * Regions:
  65. * - $page['header']: Items for the header region.
  66. * - $page['featured']: Items for the featured region.
  67. * - $page['highlighted']: Items for the highlighted content region.
  68. * - $page['help']: Dynamic help text, mostly for admin pages.
  69. * - $page['content']: The main content of the current page.
  70. * - $page['sidebar_first']: Items for the first sidebar.
  71. * - $page['triptych_first']: Items for the first triptych.
  72. * - $page['triptych_middle']: Items for the middle triptych.
  73. * - $page['triptych_last']: Items for the last triptych.
  74. * - $page['footer_firstcolumn']: Items for the first footer column.
  75. * - $page['footer_secondcolumn']: Items for the second footer column.
  76. * - $page['footer_thirdcolumn']: Items for the third footer column.
  77. * - $page['footer_fourthcolumn']: Items for the fourth footer column.
  78. * - $page['footer']: Items for the footer region.
  79. *
  80. * @see template_preprocess()
  81. * @see template_preprocess_page()
  82. * @see template_process()
  83. * @see bartik_process_page()
  84. * @see html.tpl.php
  85. */
  86. ?>
  87. <div id="page-wrapper"><div id="page">
  88. <div id="header" class="<?php print $secondary_menu ? 'with-secondary-menu': 'without-secondary-menu'; ?>"><div class="section clearfix">
  89. <?php if ($logo): ?>
  90. <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
  91. <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
  92. </a>
  93. <?php endif; ?>
  94. <?php if ($site_name || $site_slogan): ?>
  95. <div id="name-and-slogan"<?php if ($hide_site_name && $hide_site_slogan) { print ' class="element-invisible"'; } ?>>
  96. <?php if ($site_name): ?>
  97. <?php if ($title): ?>
  98. <div id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
  99. <strong>
  100. <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
  101. </strong>
  102. </div>
  103. <?php else: /* Use h1 when the content title is empty */ ?>
  104. <h1 id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
  105. <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
  106. </h1>
  107. <?php endif; ?>
  108. <?php endif; ?>
  109. <?php if ($site_slogan): ?>
  110. <div id="site-slogan"<?php if ($hide_site_slogan) { print ' class="element-invisible"'; } ?>>
  111. <?php print $site_slogan; ?>
  112. </div>
  113. <?php endif; ?>
  114. </div> <!-- /#name-and-slogan -->
  115. <?php endif; ?>
  116. <?php print render($page['header']); ?>
  117. <?php if ($main_menu): ?>
  118. <div id="main-menu" class="navigation">
  119. <?php print theme('links__system_main_menu', array(
  120. 'links' => $main_menu,
  121. 'attributes' => array(
  122. 'id' => 'main-menu-links',
  123. 'class' => array('links', 'clearfix'),
  124. ),
  125. 'heading' => array(
  126. 'text' => t('Main menu'),
  127. 'level' => 'h2',
  128. 'class' => array('element-invisible'),
  129. ),
  130. )); ?>
  131. </div> <!-- /#main-menu -->
  132. <?php endif; ?>
  133. <?php if ($secondary_menu): ?>
  134. <div id="secondary-menu" class="navigation">
  135. <?php print theme('links__system_secondary_menu', array(
  136. 'links' => $secondary_menu,
  137. 'attributes' => array(
  138. 'id' => 'secondary-menu-links',
  139. 'class' => array('links', 'inline', 'clearfix'),
  140. ),
  141. 'heading' => array(
  142. 'text' => t('Secondary menu'),
  143. 'level' => 'h2',
  144. 'class' => array('element-invisible'),
  145. ),
  146. )); ?>
  147. </div> <!-- /#secondary-menu -->
  148. <?php endif; ?>
  149. </div></div> <!-- /.section, /#header -->
  150. <?php if ($messages): ?>
  151. <div id="messages"><div class="section clearfix">
  152. <?php print $messages; ?>
  153. </div></div> <!-- /.section, /#messages -->
  154. <?php endif; ?>
  155. <?php if ($page['featured']): ?>
  156. <div id="featured"><div class="section clearfix">
  157. <?php print render($page['featured']); ?>
  158. </div></div> <!-- /.section, /#featured -->
  159. <?php endif; ?>
  160. <div id="main-wrapper" class="clearfix"><div id="main" class="clearfix">
  161. <?php if ($breadcrumb): ?>
  162. <div id="breadcrumb"><?php print $breadcrumb; ?></div>
  163. <?php endif; ?>
  164. <?php if ($page['sidebar_first']): ?>
  165. <div id="sidebar-first" class="column sidebar"><div class="section">
  166. <?php print render($page['sidebar_first']); ?>
  167. </div></div> <!-- /.section, /#sidebar-first -->
  168. <?php endif; ?>
  169. <div id="content" class="column"><div class="section">
  170. <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
  171. <a id="main-content"></a>
  172. <?php print render($title_prefix); ?>
  173. <?php if ($title): ?>
  174. <h1 class="title" id="page-title">
  175. <?php print $title; ?>
  176. </h1>
  177. <?php endif; ?>
  178. <?php print render($title_suffix); ?>
  179. <?php if ($tabs): ?>
  180. <div class="tabs">
  181. <?php print render($tabs); ?>
  182. </div>
  183. <?php endif; ?>
  184. <?php print render($page['help']); ?>
  185. <?php if ($action_links): ?>
  186. <ul class="action-links">
  187. <?php print render($action_links); ?>
  188. </ul>
  189. <?php endif; ?>
  190. <?php print render($page['content']); ?>
  191. <?php print $feed_icons; ?>
  192. </div></div> <!-- /.section, /#content -->
  193. <?php if ($page['sidebar_second']): ?>
  194. <div id="sidebar-second" class="column sidebar"><div class="section">
  195. <?php print render($page['sidebar_second']); ?>
  196. </div></div> <!-- /.section, /#sidebar-second -->
  197. <?php endif; ?>
  198. </div></div> <!-- /#main, /#main-wrapper -->
  199. <?php if ($page['triptych_first'] || $page['triptych_middle'] || $page['triptych_last']): ?>
  200. <div id="triptych-wrapper"><div id="triptych" class="clearfix">
  201. <?php print render($page['triptych_first']); ?>
  202. <?php print render($page['triptych_middle']); ?>
  203. <?php print render($page['triptych_last']); ?>
  204. </div></div> <!-- /#triptych, /#triptych-wrapper -->
  205. <?php endif; ?>
  206. <div id="footer-wrapper"><div class="section">
  207. <?php if ($page['footer_firstcolumn'] || $page['footer_secondcolumn'] || $page['footer_thirdcolumn'] || $page['footer_fourthcolumn']): ?>
  208. <div id="footer-columns" class="clearfix">
  209. <?php print render($page['footer_firstcolumn']); ?>
  210. <?php print render($page['footer_secondcolumn']); ?>
  211. <?php print render($page['footer_thirdcolumn']); ?>
  212. <?php print render($page['footer_fourthcolumn']); ?>
  213. </div> <!-- /#footer-columns -->
  214. <?php endif; ?>
  215. <?php if ($page['footer']): ?>
  216. <div id="footer" class="clearfix">
  217. <?php print render($page['footer']); ?>
  218. </div> <!-- /#footer -->
  219. <?php endif; ?>
  220. </div></div> <!-- /.section, /#footer-wrapper -->
  221. </div></div> <!-- /#page, /#page-wrapper -->