PageRenderTime 25ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/cairn/template.php

https://github.com/roblib/cairntheme
PHP | 156 lines | 5 code | 10 blank | 141 comment | 0 complexity | 97ff3ca3b1dae820447d8ce1252d72e8 MD5 | raw file
  1. <?php
  2. // $Id: template.php,v 1.21 2009/08/12 04:25:15 johnalbin Exp $
  3. /**
  4. * @file
  5. * Contains theme override functions and preprocess functions for the theme.
  6. *
  7. * ABOUT THE TEMPLATE.PHP FILE
  8. *
  9. * The template.php file is one of the most useful files when creating or
  10. * modifying Drupal themes. You can add new regions for block content, modify
  11. * or override Drupal's theme functions, intercept or make additional
  12. * variables available to your theme, and create custom PHP logic. For more
  13. * information, please visit the Theme Developer's Guide on Drupal.org:
  14. * http://drupal.org/theme-guide
  15. *
  16. * OVERRIDING THEME FUNCTIONS
  17. *
  18. * The Drupal theme system uses special theme functions to generate HTML
  19. * output automatically. Often we wish to customize this HTML output. To do
  20. * this, we have to override the theme function. You have to first find the
  21. * theme function that generates the output, and then "catch" it and modify it
  22. * here. The easiest way to do it is to copy the original function in its
  23. * entirety and paste it here, changing the prefix from theme_ to cairn_.
  24. * For example:
  25. *
  26. * original: theme_breadcrumb()
  27. * theme override: cairn_breadcrumb()
  28. *
  29. * where cairn is the name of your sub-theme. For example, the
  30. * zen_classic theme would define a zen_classic_breadcrumb() function.
  31. *
  32. * If you would like to override any of the theme functions used in Zen core,
  33. * you should first look at how Zen core implements those functions:
  34. * theme_breadcrumbs() in zen/template.php
  35. * theme_menu_item_link() in zen/template.php
  36. * theme_menu_local_tasks() in zen/template.php
  37. *
  38. * For more information, please visit the Theme Developer's Guide on
  39. * Drupal.org: http://drupal.org/node/173880
  40. *
  41. * CREATE OR MODIFY VARIABLES FOR YOUR THEMEcairn
  42. *
  43. * Each tpl.php template file has several variables which hold various pieces
  44. * of content. You can modify those variables (or add new ones) before they
  45. * are used in the template files by using preprocess functions.
  46. *
  47. * This makes THEME_preprocess_HOOK() functions the most powerful functions
  48. * available to themers.
  49. *
  50. * It works by having one preprocess function for each template file or its
  51. * derivatives (called template suggestions). For example:
  52. * THEME_preprocess_page alters the variables for page.tpl.php
  53. * THEME_preprocess_node alters the variables for node.tpl.php or
  54. * for node-forum.tpl.php
  55. * THEME_preprocess_comment alters the variables for comment.tpl.php
  56. * THEME_preprocess_block alters the variables for block.tpl.php
  57. *
  58. * For more information on preprocess functions and template suggestions,
  59. * please visit the Theme Developer's Guide on Drupal.org:
  60. * http://drupal.org/node/223440
  61. * and http://drupal.org/node/190815#template-suggestions
  62. */
  63. /**
  64. * Implementation of HOOK_theme().
  65. */
  66. function cairn_theme(&$existing, $type, $theme, $path) {
  67. $hooks = cairntheme_theme($existing, $type, $theme, $path);
  68. // Add your theme hooks like this:
  69. /*
  70. $hooks['hook_name_here'] = array( // Details go here );
  71. */
  72. // @TODO: Needs detailed comments. Patches welcome!
  73. return $hooks;
  74. }
  75. /**
  76. * Override or insert variables into all templates.
  77. *
  78. * @param $vars
  79. * An array of variables to pass to the theme template.
  80. * @param $hook
  81. * The name of the template being rendered (name of the .tpl.php file.)
  82. */
  83. /* -- Delete this line if you want to use this function
  84. function cairn_preprocess(&$vars, $hook) {
  85. $vars['sample_variable'] = t('Lorem ipsum.');
  86. }
  87. // */
  88. /**
  89. * Override or insert variables into the page templates.
  90. *
  91. * @param $vars
  92. * An array of variables to pass to the theme template.
  93. * @param $hook
  94. * The name of the template being rendered ("page" in this case.)
  95. */
  96. /* -- Delete this line if you want to use this function
  97. function cairn_preprocess_page(&$vars, $hook) {
  98. $vars['sample_variable'] = t('Lorem ipsum.');
  99. }
  100. // */
  101. /**
  102. * Override or insert variables into the node templates.
  103. *
  104. * @param $vars
  105. * An array of variables to pass to the theme template.
  106. * @param $hook
  107. * The name of the template being rendered ("node" in this case.)
  108. */
  109. /* -- Delete this line if you want to use this function
  110. function cairn_preprocess_node(&$vars, $hook) {
  111. $vars['sample_variable'] = t('Lorem ipsum.');
  112. // Optionally, run node-type-specific preprocess functions, like
  113. // cairn_preprocess_node_page() or cairn_preprocess_node_story().
  114. $function = __FUNCTION__ . '_' . $vars['node']->type;
  115. if (function_exists($function)) {
  116. $function($vars, $hook);
  117. }
  118. }
  119. // */
  120. /**
  121. * Override or insert variables into the comment templates.
  122. *
  123. * @param $vars
  124. * An array of variables to pass to the theme template.
  125. * @param $hook
  126. * The name of the template being rendered ("comment" in this case.)
  127. */
  128. /* -- Delete this line if you want to use this function
  129. function cairn_preprocess_comment(&$vars, $hook) {
  130. $vars['sample_variable'] = t('Lorem ipsum.');
  131. }
  132. // */
  133. /**
  134. * Override or insert variables into the block templates.
  135. *
  136. * @param $vars
  137. * An array of variables to pass to the theme template.
  138. * @param $hook
  139. * The name of the template being rendered ("block" in this case.)
  140. */
  141. /* -- Delete this line if you want to use this function
  142. function cairn_preprocess_block(&$vars, $hook) {
  143. $vars['sample_variable'] = t('Lorem ipsum.');
  144. }
  145. // */