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