| 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 cdh_juarez_. |
| 23 |
* For example: |
| 24 |
* |
| 25 |
* original: theme_breadcrumb() |
| 26 |
* theme override: cdh_juarez_breadcrumb() |
| 27 |
* |
| 28 |
* where STARTERKIT 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 |
|
| 64 |
/** |
| 65 |
* Implementation of HOOK_theme(). |
| 66 |
*/ |
| 67 |
function cdh_juarez_theme(&$existing, $type, $theme, $path) { |
| 68 |
$hooks = zen_theme($existing, $type, $theme, $path); |
| 69 |
// Add your theme hooks like this: |
| 70 |
$hooks['blog_node_form'] = array( |
| 71 |
'arguments' => array('form' => NULL), |
| 72 |
'template' => 'templates/node-blog-edit' |
| 73 |
); |
| 74 |
// @TODO: Needs detailed comments. Patches welcome! |
| 75 |
return $hooks; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Override or insert variables into all templates. |
| 80 |
* |
| 81 |
* @param $vars |
| 82 |
* An array of variables to pass to the theme template. |
| 83 |
* @param $hook |
| 84 |
* The name of the template being rendered (name of the .tpl.php file.) |
| 85 |
*/ |
| 86 |
/* -- Delete this line if you want to use this function |
| 87 |
function cdh_juarez_preprocess(&$vars, $hook) { |
| 88 |
$vars['sample_variable'] = t('Lorem ipsum.'); |
| 89 |
} |
| 90 |
// */ |
| 91 |
|
| 92 |
/** |
| 93 |
* Override or insert variables into the page templates. |
| 94 |
* |
| 95 |
* @param $vars |
| 96 |
* An array of variables to pass to the theme template. |
| 97 |
* @param $hook |
| 98 |
* The name of the template being rendered ("page" in this case.) |
| 99 |
*/ |
| 100 |
/* -- Delete this line if you want to use this function |
| 101 |
function cdh_juarez_preprocess_page(&$vars, $hook) { |
| 102 |
$vars['sample_variable'] = t('Lorem ipsum.'); |
| 103 |
|
| 104 |
// To remove a class from $classes_array, use array_diff(). |
| 105 |
//$vars['classes_array'] = array_diff($vars['classes_array'], array('class-to-remove')); |
| 106 |
} |
| 107 |
// */ |
| 108 |
|
| 109 |
/** |
| 110 |
* Override or insert variables into the node templates. |
| 111 |
* |
| 112 |
* @param $vars |
| 113 |
* An array of variables to pass to the theme template. |
| 114 |
* @param $hook |
| 115 |
* The name of the template being rendered ("node" in this case.) |
| 116 |
*/ |
| 117 |
/* -- Delete this line if you want to use this function |
| 118 |
function cdh_juarez_preprocess_node(&$vars, $hook) { |
| 119 |
$vars['sample_variable'] = t('Lorem ipsum.'); |
| 120 |
|
| 121 |
// Optionally, run node-type-specific preprocess functions, like |
| 122 |
// cdh_juarez_preprocess_node_page() or cdh_juarez_preprocess_node_story(). |
| 123 |
$function = __FUNCTION__ . '_' . $vars['node']->type; |
| 124 |
if (function_exists($function)) { |
| 125 |
$function($vars, $hook); |
| 126 |
} |
| 127 |
} |
| 128 |
// */ |
| 129 |
|
| 130 |
/** |
| 131 |
* Override or insert variables into the comment templates. |
| 132 |
* |
| 133 |
* @param $vars |
| 134 |
* An array of variables to pass to the theme template. |
| 135 |
* @param $hook |
| 136 |
* The name of the template being rendered ("comment" in this case.) |
| 137 |
*/ |
| 138 |
/* -- Delete this line if you want to use this function |
| 139 |
function cdh_juarez_preprocess_comment(&$vars, $hook) { |
| 140 |
$vars['sample_variable'] = t('Lorem ipsum.'); |
| 141 |
} |
| 142 |
// */ |
| 143 |
|
| 144 |
/** |
| 145 |
* Override or insert variables into the block templates. |
| 146 |
* |
| 147 |
* @param $vars |
| 148 |
* An array of variables to pass to the theme template. |
| 149 |
* @param $hook |
| 150 |
* The name of the template being rendered ("block" in this case.) |
| 151 |
*/ |
| 152 |
/* -- Delete this line if you want to use this function |
| 153 |
function cdh_juarez_preprocess_block(&$vars, $hook) { |
| 154 |
$vars['sample_variable'] = t('Lorem ipsum.'); |
| 155 |
} |
| 156 |
// */ |