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_monterrey_.
23
 *   For example:
24
 *
25
 *     original: theme_breadcrumb()
26
 *     theme override: cdh_monterrey_breadcrumb()
27
 *
28
 *   where cdh_monterrey 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_monterrey_theme(&$existing, $type, $theme, $path) {
68
  $hooks = zen_theme($existing, $type, $theme, $path);
69
  // Add your theme hooks like this:
70
  // Add your theme hooks like this:
71
  $hooks['blog_node_form'] = array( 
72
        'arguments' => array('form' => NULL),
73
        'template' => 'templates/node-blog-edit'
74
  );
75
  // @TODO: Needs detailed comments. Patches welcome!
76
  return $hooks;
77
}
78
79
/**
80
 * Override or insert variables into all templates.
81
 *
82
 * @param $vars
83
 *   An array of variables to pass to the theme template.
84
 * @param $hook
85
 *   The name of the template being rendered (name of the .tpl.php file.)
86
 */
87
/* -- Delete this line if you want to use this function
88
function cdh_monterrey_preprocess(&$vars, $hook) {
89
  $vars['sample_variable'] = t('Lorem ipsum.');
90
}
91
// */
92
93
/**
94
 * Override or insert variables into the page templates.
95
 *
96
 * @param $vars
97
 *   An array of variables to pass to the theme template.
98
 * @param $hook
99
 *   The name of the template being rendered ("page" in this case.)
100
 */
101
/* -- Delete this line if you want to use this function
102
function cdh_monterrey_preprocess_page(&$vars, $hook) {
103
  $vars['sample_variable'] = t('Lorem ipsum.');
104
105
  // To remove a class from $classes_array, use array_diff().
106
  //$vars['classes_array'] = array_diff($vars['classes_array'], array('class-to-remove'));
107
}
108
// */
109
110
/**
111
 * Override or insert variables into the node templates.
112
 *
113
 * @param $vars
114
 *   An array of variables to pass to the theme template.
115
 * @param $hook
116
 *   The name of the template being rendered ("node" in this case.)
117
 */
118
/* -- Delete this line if you want to use this function
119
function cdh_monterrey_preprocess_node(&$vars, $hook) {
120
  $vars['sample_variable'] = t('Lorem ipsum.');
121
122
  // Optionally, run node-type-specific preprocess functions, like
123
  // cdh_monterrey_preprocess_node_page() or cdh_monterrey_preprocess_node_story().
124
  $function = __FUNCTION__ . '_' . $vars['node']->type;
125
  if (function_exists($function)) {
126
    $function($vars, $hook);
127
  }
128
}
129
// */
130
131
/**
132
 * Override or insert variables into the comment templates.
133
 *
134
 * @param $vars
135
 *   An array of variables to pass to the theme template.
136
 * @param $hook
137
 *   The name of the template being rendered ("comment" in this case.)
138
 */
139
/* -- Delete this line if you want to use this function
140
function cdh_monterrey_preprocess_comment(&$vars, $hook) {
141
  $vars['sample_variable'] = t('Lorem ipsum.');
142
}
143
// */
144
145
/**
146
 * Override or insert variables into the block templates.
147
 *
148
 * @param $vars
149
 *   An array of variables to pass to the theme template.
150
 * @param $hook
151
 *   The name of the template being rendered ("block" in this case.)
152
 */
153
/* -- Delete this line if you want to use this function
154
function cdh_monterrey_preprocess_block(&$vars, $hook) {
155
  $vars['sample_variable'] = t('Lorem ipsum.');
156
}
157
// */
158
159
/**
160
 * Implements theme_menu_item_link(), with a small hack to add a css class so we can
161
 * show an icon next to the menu item.
162
 */
163
function cdh_monterrey_menu_item_link($link) {
164
  if (empty($link['localized_options'])) {
165
    $link['localized_options'] = array();
166
  }
167
168
  // If an item is a LOCAL TASK, render it as a tab
169
  if ($link['type'] & MENU_IS_LOCAL_TASK) {
170
    $link['title'] = '<span class="tab">' . check_plain($link['title']) . '</span>';
171
    $link['localized_options']['html'] = TRUE;
172
  }
173
174
  // BEGIN custom code 
175
    $extra_span = "";
176
    if($link['menu_name']=="menu-monterrey") {
177
        $class_name = "cdhm-nav-icon-".strtolower($link['link_title']);
178
        $extra_span = "<span class=\"cdhm-nav-icon $class_name\"></span>";
179
        $link['localized_options']['html'] = 'true';
180
    }
181
  // END custom code
182
183
  return l($extra_span.$link['title'], $link['href'], $link['localized_options']);
184
}