This repository has been archived by the owner on Mar 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.php
221 lines (194 loc) · 6.91 KB
/
template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
/**
* @file
* Process theme data.
*
* Use this file to run your theme specific implimentations of theme functions,
* such preprocess, process, alters, and theme function overrides.
*
* Preprocess and process functions are used to modify or create variables for
* templates and theme functions. They are a common theming tool in Drupal, often
* used as an alternative to directly editing or adding code to templates. Its
* worth spending some time to learn more about these functions - they are a
* powerful way to easily modify the output of any template variable.
*
* Preprocess and Process Functions SEE: http://drupal.org/node/254940#variables-processor
* 1. Rename each function and instance of "corvusbie" to match
* your subthemes name, e.g. if your theme name is "footheme" then the function
* name will be "footheme_preprocess_hook". Tip - you can search/replace
* on "corvusbie".
* 2. Uncomment the required function to use.
*/
function corvusbie_css_alter(&$css) {
if (isset($css['sites/all/themes/adaptivetheme/at_core/css/at.layout.css'])) {
$css['sites/all/themes/adaptivetheme/at_core/css/at.layout.css']['media'] = 'all';
}
if (isset($css['public://adaptivetheme/corvusbie_files/corvusbie.responsive.layout.css'])) {
$css['public://adaptivetheme/corvusbie_files/corvusbie.responsive.layout.css']['media'] = 'all';
}
if (isset($css['sites/all/themes/corvusbie/css/print.css'])) {
$css['sites/all/themes/corvusbie/css/print.css']['weight'] = '1.0';
}
}
/**
* Preprocess variables for the html template.
*/
function corvusbie_preprocess_html(&$vars) {
global $theme_key;
// Add the external CSS for fonts
drupal_add_css('https://cloud.typography.com/6307052/6144772/css/fonts.css', array('type' => 'external'));
// Add body classes to course guide book pages
$courseguidepathprefix = 'research/course-guides/';
if (strncmp(request_path(), $courseguidepathprefix, strlen($courseguidepathprefix)) === 0 ){
$vars['classes_array'][] = 'course-guide-child-page';
}
// Add body classes to find/ pages
$findpathprefix = 'find/';
if (strncmp(request_path(), $findpathprefix, strlen($findpathprefix)) === 0 ){
$vars['classes_array'][] = 'find-child-page';
}
// Add body classes to services/ child pages
$servicespathprefix = 'services/';
if (strncmp(request_path(), $servicespathprefix, strlen($servicespathprefix)) === 0 ){
$vars['classes_array'][] = 'services-child-page';
}
// Add prefetch / preload tags for login and search
drupal_add_html_head_link(array(
'rel' => 'prefetch prerender',
// Force the URL to be absolute, for consistency with other <link> tags
// output by Drupal.
'href' => url('login', array(
'absolute' => TRUE,
)),
));
drupal_add_html_head_link(array(
'rel' => 'prefetch prerender',
// Force the URL to be absolute, for consistency with other <link> tags
// output by Drupal.
'href' => url('search-options', array(
'absolute' => TRUE,
)),
));
}
/**
* Process variables for the html template.
*/
/* -- Delete this line if you want to use this function
function corvusbie_process_html(&$vars) {
}
// */
/**
* Override or insert variables for the page templates.
*/
/* -- Delete this line if you want to use these functions
function corvusbie_preprocess_page(&$vars) {
}
function corvusbie_process_page(&$vars) {
}
// */
/**
* Override or insert variables into the node templates.
*/
function corvusbie_preprocess_node(&$vars) {
$vars['submitted'] = date( "F j, Y",$vars['created']);
$vars['user_picture'] = '';
}
/*
function corvusbie_process_node(&$vars) {
}
*/
/**
* Override or insert variables into the comment templates.
*/
/* -- Delete this line if you want to use these functions
function corvusbie_preprocess_comment(&$vars) {
}
function corvusbie_process_comment(&$vars) {
}
// */
/**
* Override or insert variables into the block templates.
*/
/* -- Delete this line if you want to use these functions
function corvusbie_preprocess_block(&$vars) {
}
function corvusbie_process_block(&$vars) {
}
// */
function corvusbie_preprocess_field(&$vars) {
if ($vars['element']['#field_name'] == 'field_link_to_detailed_guide') {
foreach ($vars['items'] as $delta => $item) {
$vars['items'][$delta]['#label'] = $vars['items'][$delta]['#label'] . " Subject Guide: Detailed Version";
}
} elseif ($vars['element']['#field_name'] == 'field_link_to_quick_guide') {
foreach ($vars['items'] as $delta => $item) {
$vars['items'][$delta]['#label'] = $vars['items'][$delta]['#label'] . " Quick Guide";
}
}
}
function corvusbie_admin_menu_output_alter(&$content) {
$content['menu']['imce'] = array(
"#title" => "File Browser",
"#href" => "imce",
"#weight" => -20,
);
}
function corvusbie_preprocess_username(&$variables) {
$account = $variables['account'];
$variables['extra'] = '';
if (empty($account->uid)) {
$variables['uid'] = 0;
if (theme_get_setting('toggle_comment_user_verification')) {
$variables['extra'] = ' (' . t('not verified') . ')';
}
}
else {
$variables['uid'] = (int) $account->uid;
}
// Set the name to a formatted name that is safe for printing and
// that won't break tables by being too long. Keep an unshortened,
// unsanitized version, in case other preprocess functions want to implement
// their own shortening logic or add markup. If they do so, they must ensure
// that $variables['name'] is safe for printing.
$name = $variables['name_raw'] = format_username($account);
$variables['name'] = check_plain($name);
$variables['profile_access'] = user_access('access user profiles');
$variables['link_attributes'] = array();
// Populate link path and attributes if appropriate.
if ($variables['uid'] && $variables['profile_access']) {
// We are linking to a local user.
$variables['link_attributes'] = array(
'title' => t('View user profile.'),
);
$variables['link_path'] = 'user/' . $variables['uid'];
}
elseif (!empty($account->homepage)) {
// Like the 'class' attribute, the 'rel' attribute can hold a
// space-separated set of values, so initialize it as an array to make it
// easier for other preprocess functions to append to it.
$variables['link_attributes'] = array(
'rel' => array(
'nofollow',
),
);
$variables['link_path'] = $account->homepage;
$variables['homepage'] = $account->homepage;
}
// We do not want the l() function to check_plain() a second time.
$variables['link_options']['html'] = TRUE;
// Set a default class.
$variables['attributes_array'] = array(
'class' => array(
'username',
),
);
}
//Jump to the first result if there's only one result.
function corvusbie_preprocess_views_view(&$vars) {
$view = $vars['view'];
if ($view->name == 'databases_title' && $view->current_display == 'page') {
if (count($view->result)==1){
drupal_goto('node/' . $view->result[0]->nid);
}
}
}