/template.php

https://github.com/bachos/fudcon_website_theme · PHP · 188 lines · 33 code · 12 blank · 143 comment · 4 complexity · c600c1c9d696d91b53f9ac4b75ed2a84 MD5 · raw file

  1. <?php
  2. /**
  3. * @file
  4. * Contains theme override functions and preprocess functions for the theme.
  5. *
  6. * ABOUT THE TEMPLATE.PHP FILE
  7. *
  8. * The template.php file is one of the most useful files when creating or
  9. * modifying Drupal themes. You can add new regions for block content, modify
  10. * or override Drupal's theme functions, intercept or make additional
  11. * variables available to your theme, and create custom PHP logic. For more
  12. * information, please visit the Theme Developer's Guide on Drupal.org:
  13. * http://drupal.org/theme-guide
  14. *
  15. * OVERRIDING THEME FUNCTIONS
  16. *
  17. * The Drupal theme system uses special theme functions to generate HTML
  18. * output automatically. Often we wish to customize this HTML output. To do
  19. * this, we have to override the theme function. You have to first find the
  20. * theme function that generates the output, and then "catch" it and modify it
  21. * here. The easiest way to do it is to copy the original function in its
  22. * entirety and paste it here, changing the prefix from theme_ to fudcon_.
  23. * For example:
  24. *
  25. * original: theme_breadcrumb()
  26. * theme override: fudcon_breadcrumb()
  27. *
  28. * where fudcon is the name of your sub-theme. For example, the
  29. * zen_classic theme would define a zen_classic_breadcrumb() function.
  30. *
  31. * If you would like to override any of the theme functions used in Zen core,
  32. * you should first look at how Zen core implements those functions:
  33. * theme_breadcrumbs() in zen/template.php
  34. * theme_menu_item_link() in zen/template.php
  35. * theme_menu_local_tasks() in zen/template.php
  36. *
  37. * For more information, please visit the Theme Developer's Guide on
  38. * Drupal.org: http://drupal.org/node/173880
  39. *
  40. * CREATE OR MODIFY VARIABLES FOR YOUR THEME
  41. *
  42. * Each tpl.php template file has several variables which hold various pieces
  43. * of content. You can modify those variables (or add new ones) before they
  44. * are used in the template files by using preprocess functions.
  45. *
  46. * This makes THEME_preprocess_HOOK() functions the most powerful functions
  47. * available to themers.
  48. *
  49. * It works by having one preprocess function for each template file or its
  50. * derivatives (called template suggestions). For example:
  51. * THEME_preprocess_page alters the variables for page.tpl.php
  52. * THEME_preprocess_node alters the variables for node.tpl.php or
  53. * for node-forum.tpl.php
  54. * THEME_preprocess_comment alters the variables for comment.tpl.php
  55. * THEME_preprocess_block alters the variables for block.tpl.php
  56. *
  57. * For more information on preprocess functions and template suggestions,
  58. * please visit the Theme Developer's Guide on Drupal.org:
  59. * http://drupal.org/node/223440
  60. * and http://drupal.org/node/190815#template-suggestions
  61. */
  62. /**
  63. * Implementation of HOOK_theme().
  64. */
  65. function fudcon_theme(&$existing, $type, $theme, $path) {
  66. $hooks = zen_theme($existing, $type, $theme, $path);
  67. // Add your theme hooks like this:
  68. /*
  69. $hooks['hook_name_here'] = array( // Details go here );
  70. */
  71. // @TODO: Needs detailed comments. Patches welcome!
  72. return $hooks;
  73. }
  74. /**
  75. * Override or insert variables into all templates.
  76. *
  77. * @param $vars
  78. * An array of variables to pass to the theme template.
  79. * @param $hook
  80. * The name of the template being rendered (name of the .tpl.php file.)
  81. */
  82. /* -- Delete this line if you want to use this function
  83. function fudcon_preprocess(&$vars, $hook) {
  84. $vars['sample_variable'] = t('Lorem ipsum.');
  85. }
  86. // */
  87. /**
  88. * Override or insert variables into the page templates.
  89. *
  90. * @param $vars
  91. * An array of variables to pass to the theme template.
  92. * @param $hook
  93. * The name of the template being rendered ("page" in this case.)
  94. */
  95. /* -- Delete this line if you want to use this function
  96. function fudcon_preprocess_page(&$vars, $hook) {
  97. $vars['sample_variable'] = t('Lorem ipsum.');
  98. // To remove a class from $classes_array, use array_diff().
  99. //$vars['classes_array'] = array_diff($vars['classes_array'], array('class-to-remove'));
  100. }
  101. // */
  102. /**
  103. * Override or insert variables into the node templates.
  104. *
  105. * @param $vars
  106. * An array of variables to pass to the theme template.
  107. * @param $hook
  108. * The name of the template being rendered ("node" in this case.)
  109. */
  110. /* -- Delete this line if you want to use this function
  111. function fudcon_preprocess_node(&$vars, $hook) {
  112. $vars['sample_variable'] = t('Lorem ipsum.');
  113. // Optionally, run node-type-specific preprocess functions, like
  114. // fudcon_preprocess_node_page() or fudcon_preprocess_node_story().
  115. $function = __FUNCTION__ . '_' . $vars['node']->type;
  116. if (function_exists($function)) {
  117. $function($vars, $hook);
  118. }
  119. }
  120. // */
  121. /**
  122. * Override or insert variables into the comment templates.
  123. *
  124. * @param $vars
  125. * An array of variables to pass to the theme template.
  126. * @param $hook
  127. * The name of the template being rendered ("comment" in this case.)
  128. */
  129. /* -- Delete this line if you want to use this function
  130. function fudcon_preprocess_comment(&$vars, $hook) {
  131. $vars['sample_variable'] = t('Lorem ipsum.');
  132. }
  133. // */
  134. /**
  135. * Override or insert variables into the block templates.
  136. *
  137. * @param $vars
  138. * An array of variables to pass to the theme template.
  139. * @param $hook
  140. * The name of the template being rendered ("block" in this case.)
  141. */
  142. /* -- Delete this line if you want to use this function
  143. function fudcon_preprocess_block(&$vars, $hook) {
  144. $vars['sample_variable'] = t('Lorem ipsum.');
  145. }
  146. // */
  147. function fudcon_filter_menu_tree($menu_name) {
  148. $tree = menu_tree_all_data($menu_name);
  149. $final = array();
  150. foreach($tree as $link) {
  151. $item = $link['link'];
  152. if ($item['hidden'] == 0) {
  153. $below = array();
  154. if ($link['below']) {
  155. foreach($link['below'] as $blink) {
  156. if (!empty($blink['link']['title'])) {
  157. $below[] = array(
  158. 'href' => $blink['link']['href'],
  159. 'title' => $blink['link']['title'],
  160. );
  161. }
  162. }
  163. }
  164. $final[] = array(
  165. 'href' => $link['link']['href'],
  166. 'title' => $link['link']['title'],
  167. 'below' => $below,
  168. );
  169. }
  170. }
  171. return $final;
  172. }
  173. drupal_add_js(drupal_get_path('theme', 'fudcon') . '/js/jquery.autofill.js');
  174. drupal_add_js(drupal_get_path('theme', 'fudcon') . '/js/searchbox.js');