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