page.tpl.php

You are here

  1. 7 themes/garland/page.tpl.php
  2. 7 modules/block/tests/themes/block_test_theme/page.tpl.php
  3. 7 themes/bartik/templates/page.tpl.php
  4. 7 modules/system/page.tpl.php
  5. 7 themes/seven/page.tpl.php
  6. 4.7 themes/pushbutton/page.tpl.php
  7. 4.7 themes/bluemarine/page.tpl.php
  8. 5 themes/bluemarine/page.tpl.php
  9. 5 themes/pushbutton/page.tpl.php
  10. 5 themes/garland/page.tpl.php
  11. 6 themes/pushbutton/page.tpl.php
  12. 6 themes/garland/page.tpl.php
  13. 6 themes/bluemarine/page.tpl.php
  14. 6 modules/system/page.tpl.php

Default 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 in this 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.

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['help']: Dynamic help text, mostly for admin pages.
  • $page['highlighted']: Items for the highlighted content region.
  • $page['content']: The main content of the current page.
  • $page['sidebar_first']: Items for the first sidebar.
  • $page['sidebar_second']: Items for the second sidebar.
  • $page['header']: Items for the header region.
  • $page['footer']: Items for the footer region.

See also

template_preprocess()

template_preprocess_page()

template_process()

html.tpl.php

File

modules/system/page.tpl.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Default 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 in this directory.
  8. *
  9. * Available variables:
  10. *
  11. * General utility variables:
  12. * - $base_path: The base URL path of the Drupal installation. At the very
  13. * least, this will always default to /.
  14. * - $directory: The directory the template is located in, e.g. modules/system
  15. * or themes/bartik.
  16. * - $is_front: TRUE if the current page is the front page.
  17. * - $logged_in: TRUE if the user is registered and signed in.
  18. * - $is_admin: TRUE if the user has permission to access administration pages.
  19. *
  20. * Site identity:
  21. * - $front_page: The URL of the front page. Use this instead of $base_path,
  22. * when linking to the front page. This includes the language domain or
  23. * prefix.
  24. * - $logo: The path to the logo image, as defined in theme configuration.
  25. * - $site_name: The name of the site, empty when display has been disabled
  26. * in theme settings.
  27. * - $site_slogan: The slogan of the site, empty when display has been disabled
  28. * in theme settings.
  29. *
  30. * Navigation:
  31. * - $main_menu (array): An array containing the Main menu links for the
  32. * site, if they have been configured.
  33. * - $secondary_menu (array): An array containing the Secondary menu links for
  34. * the site, if they have been configured.
  35. * - $breadcrumb: The breadcrumb trail for the current page.
  36. *
  37. * Page content (in order of occurrence in the default page.tpl.php):
  38. * - $title_prefix (array): An array containing additional output populated by
  39. * modules, intended to be displayed in front of the main title tag that
  40. * appears in the template.
  41. * - $title: The page title, for use in the actual HTML content.
  42. * - $title_suffix (array): An array containing additional output populated by
  43. * modules, intended to be displayed after the main title tag that appears in
  44. * the template.
  45. * - $messages: HTML for status and error messages. Should be displayed
  46. * prominently.
  47. * - $tabs (array): Tabs linking to any sub-pages beneath the current page
  48. * (e.g., the view and edit tabs when displaying a node).
  49. * - $action_links (array): Actions local to the page, such as 'Add menu' on the
  50. * menu administration interface.
  51. * - $feed_icons: A string of all feed icons for the current page.
  52. * - $node: The node object, if there is an automatically-loaded node
  53. * associated with the page, and the node ID is the second argument
  54. * in the page's path (e.g. node/12345 and node/12345/revisions, but not
  55. * comment/reply/12345).
  56. *
  57. * Regions:
  58. * - $page['help']: Dynamic help text, mostly for admin pages.
  59. * - $page['highlighted']: Items for the highlighted content region.
  60. * - $page['content']: The main content of the current page.
  61. * - $page['sidebar_first']: Items for the first sidebar.
  62. * - $page['sidebar_second']: Items for the second sidebar.
  63. * - $page['header']: Items for the header region.
  64. * - $page['footer']: Items for the footer region.
  65. *
  66. * @see template_preprocess()
  67. * @see template_preprocess_page()
  68. * @see template_process()
  69. * @see html.tpl.php
  70. *
  71. * @ingroup themeable
  72. */
  73. ?>
  74. <div id="page-wrapper"><div id="page">
  75. <div id="header"><div class="section clearfix">
  76. <?php if ($logo): ?>
  77. <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
  78. <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
  79. </a>
  80. <?php endif; ?>
  81. <?php if ($site_name || $site_slogan): ?>
  82. <div id="name-and-slogan">
  83. <?php if ($site_name): ?>
  84. <?php if ($title): ?>
  85. <div id="site-name"><strong>
  86. <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
  87. </strong></div>
  88. <?php else: /* Use h1 when the content title is empty */ ?>
  89. <h1 id="site-name">
  90. <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
  91. </h1>
  92. <?php endif; ?>
  93. <?php endif; ?>
  94. <?php if ($site_slogan): ?>
  95. <div id="site-slogan"><?php print $site_slogan; ?></div>
  96. <?php endif; ?>
  97. </div> <!-- /#name-and-slogan -->
  98. <?php endif; ?>
  99. <?php print render($page['header']); ?>
  100. </div></div> <!-- /.section, /#header -->
  101. <?php if ($main_menu || $secondary_menu): ?>
  102. <div id="navigation"><div class="section">
  103. <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Main menu'))); ?>
  104. <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Secondary menu'))); ?>
  105. </div></div> <!-- /.section, /#navigation -->
  106. <?php endif; ?>
  107. <?php if ($breadcrumb): ?>
  108. <div id="breadcrumb"><?php print $breadcrumb; ?></div>
  109. <?php endif; ?>
  110. <?php print $messages; ?>
  111. <div id="main-wrapper"><div id="main" class="clearfix">
  112. <div id="content" class="column"><div class="section">
  113. <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
  114. <a id="main-content"></a>
  115. <?php print render($title_prefix); ?>
  116. <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
  117. <?php print render($title_suffix); ?>
  118. <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?>
  119. <?php print render($page['help']); ?>
  120. <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
  121. <?php print render($page['content']); ?>
  122. <?php print $feed_icons; ?>
  123. </div></div> <!-- /.section, /#content -->
  124. <?php if ($page['sidebar_first']): ?>
  125. <div id="sidebar-first" class="column sidebar"><div class="section">
  126. <?php print render($page['sidebar_first']); ?>
  127. </div></div> <!-- /.section, /#sidebar-first -->
  128. <?php endif; ?>
  129. <?php if ($page['sidebar_second']): ?>
  130. <div id="sidebar-second" class="column sidebar"><div class="section">
  131. <?php print render($page['sidebar_second']); ?>
  132. </div></div> <!-- /.section, /#sidebar-second -->
  133. <?php endif; ?>
  134. </div></div> <!-- /#main, /#main-wrapper -->
  135. <div id="footer"><div class="section">
  136. <?php print render($page['footer']); ?>
  137. </div></div> <!-- /.section, /#footer -->
  138. </div></div> <!-- /#page, /#page-wrapper -->

Related topics

Comments

This is not in the default implementation, but I find it helpful on my page template files. Here's a simple snippet for your template.php _preprocess_page() function:

<?php
function themename_preprocess_page(&$variables) {
    if (
overlay_get_mode() == 'child') {
       
$variables['renderingOverlay'] = TRUE;
    } else {
       
$variables['renderingOverlay'] = FALSE;
    }
}
?>

That makes available a $renderingOverlay variable for your page template files so you could omit certain regions. I am using as follows to not render my 'right_column' region:

<?php if (! $renderingOverlay): ?>
<div class="right-column-region">
<?php print render($page['right_column']); ?>
</div>
<?php endif;?>

Worked in preprocess page.

But if you invoke overlay_get_mode() in preprocess_html it will always return 'parent' no matter what.

Checkout this for other drupal 7 theming tutorial
http://drupal.org/node/1089656

---
Website Development Services

If you are having trouble getting a region to appear there's a slight (but important) difference between D6 and D7.

D6:

<?php
print $content;
?>

D7:

<?php
print render($page['content']);
?>

All regions need to be placed into render() before it can be printed. I looked forever before I happened upon this tidbit and thought it might be useful to mention for other themers.

The tabs div is being always output in Drupal 7 (even when there are no tabs for the user) and can cause styling issues. To only print the div when necessary you could use the following code:

<?php if ($tabs = render($tabs)): ?><div class="tabs"><?php print $tabs; ?></div><?php endif; ?>

This is not a question, however it is a solution which worked for me with $pager contents.

I wanted to show pager display beside the title, I was worried to work hard on CSS to show it off. One Geek guided me shift render code to desired place

   <?php if ($pager): ?>
        <?php print $pager; ?>
    <?php endif; ?>

which is simple solution and Solved my problem.

Thanks to Geeks!!!

Hi,

I have upgraded my web for testing from drupal 6 to 7. I have modified the page.tpl to display content and footer using render function but it is not rendering the content. But the content is there in the array. Following is the print_r output for $page['footer']

Array
(
[block_9] => Array
(
[#markup] =>

Physical Address Address

[#contextual_links] => Array
(
[block] => Array
(
[0] => admin/structure/block/manage
[1] => Array
(
[0] => block
[1] => 9
)
)
)
[#block] => stdClass Object
(
[bid] => 673
[module] => block
[delta] => 9
[theme] => cz
[status] => 1
[weight] => -29
[region] => footer
[custom] => 0
[visibility] => 0
[pages] =>
[title] =>
[cache] => -1
[subject] =>
)
[#weight] => 1
[#theme_wrappers] => Array
(
[0] => block
)
)
[#sorted] => 1
[#theme_wrappers] => Array
(
[0] => region
)
[#region] => footer
)

Can some one help me to solve this problem?

Thanks in advance