template.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Implements hook_html_head_alter().
  4. * This will overwrite the default meta character type tag with HTML5 version.
  5. */
  6. function rainbow_html_head_alter(&$head_elements) {
  7. $head_elements['system_meta_content_type']['#attributes'] = array(
  8. 'charset' => 'utf-8'
  9. );
  10. }
  11. /**
  12. * Insert themed breadcrumb page navigation at top of the node content.
  13. */
  14. function rainbow_breadcrumb($variables) {
  15. $breadcrumb = $variables['breadcrumb'];
  16. if (!empty($breadcrumb)) {
  17. // Use CSS to hide titile .element-invisible.
  18. $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
  19. // comment below line to hide current page to breadcrumb
  20. $breadcrumb[] = drupal_get_title();
  21. $output .= '<nav class="breadcrumb">' . implode(' » ', $breadcrumb) . '</nav>';
  22. return $output;
  23. }
  24. }
  25. /**
  26. * Override or insert variables into the page template.
  27. */
  28. function rainbow_preprocess_page(&$vars) {
  29. if (isset($vars['main_menu'])) {
  30. $vars['main_menu'] = theme('links__system_main_menu', array(
  31. 'links' => $vars['main_menu'],
  32. 'attributes' => array(
  33. 'class' => array('links', 'main-menu', 'clearfix'),
  34. ),
  35. 'heading' => array(
  36. 'text' => t('Main menu'),
  37. 'level' => 'h2',
  38. 'class' => array('element-invisible'),
  39. )
  40. ));
  41. }
  42. else {
  43. $vars['main_menu'] = FALSE;
  44. }
  45. if (isset($vars['secondary_menu'])) {
  46. $vars['secondary_menu'] = theme('links__system_secondary_menu', array(
  47. 'links' => $vars['secondary_menu'],
  48. 'attributes' => array(
  49. 'class' => array('links', 'secondary-menu', 'clearfix'),
  50. ),
  51. 'heading' => array(
  52. 'text' => t('Secondary menu'),
  53. 'level' => 'h2',
  54. 'class' => array('element-invisible'),
  55. )
  56. ));
  57. }
  58. else {
  59. $vars['secondary_menu'] = FALSE;
  60. }
  61. }
  62. /**
  63. * Duplicate of theme_menu_local_tasks() but adds clearfix to tabs.
  64. */
  65. function rainbow_menu_local_tasks(&$variables) {
  66. $output = '';
  67. if (!empty($variables['primary'])) {
  68. $variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
  69. $variables['primary']['#prefix'] .= '<ul class="tabs primary clearfix">';
  70. $variables['primary']['#suffix'] = '</ul>';
  71. $output .= drupal_render($variables['primary']);
  72. }
  73. if (!empty($variables['secondary'])) {
  74. $variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
  75. $variables['secondary']['#prefix'] .= '<ul class="tabs secondary clearfix">';
  76. $variables['secondary']['#suffix'] = '</ul>';
  77. $output .= drupal_render($variables['secondary']);
  78. }
  79. return $output;
  80. }
  81. /**
  82. * Override or insert variables into the node template.
  83. */
  84. function rainbow_preprocess_node(&$variables) {
  85. $node = $variables['node'];
  86. if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
  87. $variables['classes_array'][] = 'node-full';
  88. }
  89. }
  90. // function rainbow_page_alter($page) {
  91. // // <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
  92. // $viewport = array(
  93. // '#type' => 'html_tag',
  94. // '#tag' => 'meta',
  95. // '#attributes' => array(
  96. // 'name' => 'viewport',
  97. // 'content' => 'width=device-width'
  98. // )
  99. // );
  100. // drupal_add_html_head($viewport, 'viewport');
  101. // }