| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: template.php,v 1.17.2.1 2009/02/13 06:47:44 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 gatewave_. 25 * For example: 26 * 27 * original: theme_breadcrumb() 28 * theme override: gatewave_breadcrumb() 29 * 30 * where gatewave 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 74 // Example: optionally add a fixed width CSS file. 75 if (theme_get_setting('gatewave_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 gatewave_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 gatewave_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 gatewave_preprocess_page(&$vars, $hook) { 118 $vars['sample_variable'] = t('Lorem ipsum.'); 119 } 120 // */ 121 122 /** 123 * Override or insert variables into the node templates. 124 * 125 * @param $vars 126 * An array of variables to pass to the theme template. 127 * @param $hook 128 * The name of the template being rendered ("node" in this case.) 129 */ 130 /* -- Delete this line if you want to use this function 131 function gatewave_preprocess_node(&$vars, $hook) { 132 $vars['sample_variable'] = t('Lorem ipsum.'); 133 } 134 // */ 135 136 /** 137 * Override or insert variables into the comment templates. 138 * 139 * @param $vars 140 * An array of variables to pass to the theme template. 141 * @param $hook 142 * The name of the template being rendered ("comment" in this case.) 143 */ 144 /* -- Delete this line if you want to use this function 145 function gatewave_preprocess_comment(&$vars, $hook) { 146 $vars['sample_variable'] = t('Lorem ipsum.'); 147 } 148 // */ 149 150 /** 151 * Override or insert variables into the block templates. 152 * 153 * @param $vars 154 * An array of variables to pass to the theme template. 155 * @param $hook 156 * The name of the template being rendered ("block" in this case.) 157 */ 158 /* -- Delete this line if you want to use this function 159 function gatewave_preprocess_block(&$vars, $hook) { 160 $vars['sample_variable'] = t('Lorem ipsum.'); 161 } 162 // */ 163 164 165 166 function gatewave_nice_menu_build_x($menu, $main_menu=true) { 167 $output = ''; 168 foreach ($menu as $menu_item) { 169 $mlid = $menu_item['link']['mlid']; 170 // Check to see if it is a visible menu item. 171 if ($menu_item['link']['hidden'] != 0) 172 continue; 173 $clean_path = str_replace(array('http://', '<', '>', '&', '=', '?', ':'), '', $menu_item['link']['href']); //Strip symbols. 174 // Convert slashes to dashes. 175 $clean_path = str_replace('/', '-', $clean_path); 176 $current_node = str_replace('node-', '', $clean_path); 177 $path_class = 'menu-path-'. $clean_path; 178 if ($current_node == $GLOBALS['active_node']) { 179 $path_class.= ' active-content'; 180 } 181 $children = ''; 182 // If it has children build a nice little tree under it. 183 if ((!empty($menu_item['link']['has_children'])) && (!empty($menu_item['below']))) { 184 $is_child = true; // Keep passing children into the function 'til we get them all. 185 $children = theme('nice_menu_build', $menu_item['below'], false); 186 $children = ($children)?"<ul>$children</ul>\n":''; 187 // Set the class to parent only of children are displayed. 188 $parent_class = $children ? 'menuparent ' : ''; 189 } 190 191 // Build the child UL only if there is a child menu 192 if($main_menu){ 193 $output .= "<td id='menu-$mlid' class='{$parent_class}{$path_class}'>".theme('menu_item_link', $menu_item['link'])."$children</td>"; 194 //Adds some extra separators after each td 195 $output .= "<td><span class='sep1'></span></td>\n"; 196 }else { 197 $output .= "<li id='menu-$mlid' class='{$parent_class}{$path_class}'>".theme('menu_item_link', $menu_item['link'])."$children</li>"; 198 } 199 } 200 return $output; 201 } 202 203 function gatewave_nice_menu_x($id, $menu_name, $mlid, $direction = 'right', $menu = NULL) { 204 $output = array(); 205 if ($menu_tree = theme('nice_menu_tree', $menu_name, $mlid, $menu)) { 206 if ($menu_tree['content']) { 207 $output['content'] = '<table width="100%" class="site-menu"><tr>' .$menu_tree['content'] .'</tr></table>'."\n"; 208 $output['subject'] = $menu_tree['subject']; 209 } 210 } 211 return $output; 212 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |