template.php

  1. 7.x drupal-7.x/themes/seven/template.php
  2. 7.x drupal-7.x/themes/garland/template.php
  3. 7.x drupal-7.x/themes/bartik/template.php
  4. 7.x drupal-7.x/modules/simpletest/tests/themes/test_theme/template.php
  5. 6.x drupal-6.x/themes/garland/template.php

File

drupal-7.x/themes/garland/template.php
View source
  1. <?php
  2. /**
  3. * Override of theme_breadcrumb().
  4. */
  5. function garland_breadcrumb($variables) {
  6. $breadcrumb = $variables['breadcrumb'];
  7. if (!empty($breadcrumb)) {
  8. // Provide a navigational heading to give context for breadcrumb links to
  9. // screen-reader users. Make the heading invisible with .element-invisible.
  10. $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
  11. $output .= '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';
  12. return $output;
  13. }
  14. }
  15. /**
  16. * Override or insert variables into the maintenance page template.
  17. */
  18. function garland_preprocess_maintenance_page(&$vars) {
  19. // While markup for normal pages is split into page.tpl.php and html.tpl.php,
  20. // the markup for the maintenance page is all in the single
  21. // maintenance-page.tpl.php template. So, to have what's done in
  22. // garland_preprocess_html() also happen on the maintenance page, it has to be
  23. // called here.
  24. garland_preprocess_html($vars);
  25. }
  26. /**
  27. * Override or insert variables into the html template.
  28. */
  29. function garland_preprocess_html(&$vars) {
  30. // Toggle fixed or fluid width.
  31. if (theme_get_setting('garland_width') == 'fluid') {
  32. $vars['classes_array'][] = 'fluid-width';
  33. }
  34. // Add conditional CSS for IE6.
  35. drupal_add_css(path_to_theme() . '/fix-ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lt IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
  36. }
  37. /**
  38. * Override or insert variables into the html template.
  39. */
  40. function garland_process_html(&$vars) {
  41. // Hook into color.module
  42. if (module_exists('color')) {
  43. _color_html_alter($vars);
  44. }
  45. }
  46. /**
  47. * Override or insert variables into the page template.
  48. */
  49. function garland_preprocess_page(&$vars) {
  50. // Move secondary tabs into a separate variable.
  51. $vars['tabs2'] = array(
  52. '#theme' => 'menu_local_tasks',
  53. '#secondary' => $vars['tabs']['#secondary'],
  54. );
  55. unset($vars['tabs']['#secondary']);
  56. if (isset($vars['main_menu'])) {
  57. $vars['primary_nav'] = theme('links__system_main_menu', array(
  58. 'links' => $vars['main_menu'],
  59. 'attributes' => array(
  60. 'class' => array('links', 'inline', 'main-menu'),
  61. ),
  62. 'heading' => array(
  63. 'text' => t('Main menu'),
  64. 'level' => 'h2',
  65. 'class' => array('element-invisible'),
  66. )
  67. ));
  68. }
  69. else {
  70. $vars['primary_nav'] = FALSE;
  71. }
  72. if (isset($vars['secondary_menu'])) {
  73. $vars['secondary_nav'] = theme('links__system_secondary_menu', array(
  74. 'links' => $vars['secondary_menu'],
  75. 'attributes' => array(
  76. 'class' => array('links', 'inline', 'secondary-menu'),
  77. ),
  78. 'heading' => array(
  79. 'text' => t('Secondary menu'),
  80. 'level' => 'h2',
  81. 'class' => array('element-invisible'),
  82. )
  83. ));
  84. }
  85. else {
  86. $vars['secondary_nav'] = FALSE;
  87. }
  88. // Prepare header.
  89. $site_fields = array();
  90. if (!empty($vars['site_name'])) {
  91. $site_fields[] = $vars['site_name'];
  92. }
  93. if (!empty($vars['site_slogan'])) {
  94. $site_fields[] = $vars['site_slogan'];
  95. }
  96. $vars['site_title'] = implode(' ', $site_fields);
  97. if (!empty($site_fields)) {
  98. $site_fields[0] = '<span>' . $site_fields[0] . '</span>';
  99. }
  100. $vars['site_html'] = implode(' ', $site_fields);
  101. // Set a variable for the site name title and logo alt attributes text.
  102. $slogan_text = $vars['site_slogan'];
  103. $site_name_text = $vars['site_name'];
  104. $vars['site_name_and_slogan'] = $site_name_text . ' ' . $slogan_text;
  105. }
  106. /**
  107. * Override or insert variables into the node template.
  108. */
  109. function garland_preprocess_node(&$vars) {
  110. $vars['submitted'] = $vars['date'] . ' — ' . $vars['name'];
  111. }
  112. /**
  113. * Override or insert variables into the comment template.
  114. */
  115. function garland_preprocess_comment(&$vars) {
  116. $vars['submitted'] = $vars['created'] . ' — ' . $vars['author'];
  117. }
  118. /**
  119. * Override or insert variables into the block template.
  120. */
  121. function garland_preprocess_block(&$vars) {
  122. $vars['title_attributes_array']['class'][] = 'title';
  123. $vars['classes_array'][] = 'clearfix';
  124. }
  125. /**
  126. * Override or insert variables into the page template.
  127. */
  128. function garland_process_page(&$vars) {
  129. // Hook into color.module
  130. if (module_exists('color')) {
  131. _color_page_alter($vars);
  132. }
  133. }
  134. /**
  135. * Override or insert variables into the region template.
  136. */
  137. function garland_preprocess_region(&$vars) {
  138. if ($vars['region'] == 'header') {
  139. $vars['classes_array'][] = 'clearfix';
  140. }
  141. }