Mercurial > hg > mpiwgzen_wide
comparison template.php @ 0:a3750d724105 default tip
initital
author | Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 02 Jun 2015 09:16:36 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a3750d724105 |
---|---|
1 <?php | |
2 /** | |
3 * @file | |
4 * Contains the theme's functions to manipulate Drupal's default markup. | |
5 * | |
6 * Complete documentation for this file is available online. | |
7 * @see https://drupal.org/node/1728096 | |
8 */ | |
9 | |
10 | |
11 /** | |
12 * Override or insert variables into the maintenance page template. | |
13 * | |
14 * @param $variables | |
15 * An array of variables to pass to the theme template. | |
16 * @param $hook | |
17 * The name of the template being rendered ("maintenance_page" in this case.) | |
18 */ | |
19 | |
20 function mpiwgzen_wide_preprocess_maintenance_page(&$variables, $hook) { | |
21 // When a variable is manipulated or added in preprocess_html or | |
22 // preprocess_page, that same work is probably needed for the maintenance page | |
23 // as well, so we can just re-use those functions to do that work here. | |
24 mpiwgzen_wide_preprocess_html($variables, $hook); | |
25 mpiwgzen_wide_preprocess_page($variables, $hook); | |
26 } | |
27 // */ | |
28 | |
29 /** | |
30 * Override or insert variables into the html templates. | |
31 * | |
32 * @param $variables | |
33 * An array of variables to pass to the theme template. | |
34 * @param $hook | |
35 * The name of the template being rendered ("html" in this case.) | |
36 */ | |
37 | |
38 function mpiwgzen_wide_preprocess_html(&$variables, $hook) { | |
39 $variables['sample_variable'] = t('Lorem ipsum.'); | |
40 | |
41 // The body tag's classes are controlled by the $classes_array variable. To | |
42 // remove a class from $classes_array, use array_diff(). | |
43 //$variables['classes_array'] = array_diff($variables['classes_array'], array('class-to-remove')); | |
44 } | |
45 // */ | |
46 | |
47 /** | |
48 * Override or insert variables into the page templates. | |
49 * | |
50 * @param $variables | |
51 * An array of variables to pass to the theme template. | |
52 * @param $hook | |
53 * The name of the template being rendered ("page" in this case.) | |
54 */ | |
55 | |
56 function mpiwgzen_wide_preprocess_page(&$variables, $hook) { | |
57 $variables['sample_variable'] = t('Lorem ipsum.'); | |
58 // Change the logo for logged in users. | |
59 //if (!user_is_logged_in()) { | |
60 // $variables['logo'] = 'http://echo-dev.rz-berlin.mpg.de/echo-dev/sites/all/themes/mpiwgzen_wide/echo-logo-extern.png'; | |
61 //} | |
62 } | |
63 | |
64 // */ | |
65 | |
66 /** | |
67 * Override or insert variables into the node templates. | |
68 * | |
69 * @param $variables | |
70 * An array of variables to pass to the theme template. | |
71 * @param $hook | |
72 * The name of the template being rendered ("node" in this case.) | |
73 */ | |
74 | |
75 /** | |
76 * Also change text of "read more" depending on content type | |
77 * as explained on | |
78 * http://www.dreamleaf.co.uk/drupal/drupal-7-custom-read-more-links-content-type | |
79 */ | |
80 | |
81 function mpiwgzen_wide_preprocess_node(&$variables, $hook) { | |
82 $variables['sample_variable'] = t('Lorem ipsum.'); | |
83 | |
84 // Optionally, run node-type-specific preprocess functions, like | |
85 // mpiwgzen_wide_preprocess_node_page() or mpiwgzen_wide_preprocess_node_story(). | |
86 $function = __FUNCTION__ . '_' . $variables['node']->type; | |
87 if (function_exists($function)) { | |
88 $function($variables, $hook); | |
89 } | |
90 // Let's get that read more link out of the generated links variable! | |
91 unset($variables['content']['links']['node']['#links']['node-readmore']); | |
92 // Now let's put it back as it's own variable! So it's actually versatile! | |
93 if ($variables['type'] == 'digitalcollection') { | |
94 $variables['newreadmore'] = t('<span class="digitalcollectionmore"> <a href="!title">view collection</a> </span>', | |
95 array('!title' => $variables['node_url'],) | |
96 ); | |
97 } | |
98 else { | |
99 $variables['newreadmore'] = t('<span class="newreadmore"> <a href="!title">read more</a> </span>', | |
100 array('!title' => $variables['node_url'],) | |
101 ); | |
102 } | |
103 | |
104 } | |
105 | |
106 | |
107 // */ | |
108 | |
109 /** | |
110 * Override or insert variables into the comment templates. | |
111 * | |
112 * @param $variables | |
113 * An array of variables to pass to the theme template. | |
114 * @param $hook | |
115 * The name of the template being rendered ("comment" in this case.) | |
116 */ | |
117 | |
118 function mpiwgzen_wide_preprocess_comment(&$variables, $hook) { | |
119 $variables['sample_variable'] = t('Lorem ipsum.'); | |
120 } | |
121 // */ | |
122 | |
123 /** | |
124 * Override or insert variables into the region templates. | |
125 * | |
126 * @param $variables | |
127 * An array of variables to pass to the theme template. | |
128 * @param $hook | |
129 * The name of the template being rendered ("region" in this case.) | |
130 */ | |
131 | |
132 function mpiwgzen_wide_preprocess_region(&$variables, $hook) { | |
133 // Don't use Zen's region--sidebar.tpl.php template for sidebars. | |
134 //if (strpos($variables['region'], 'sidebar_') === 0) { | |
135 // $variables['theme_hook_suggestions'] = array_diff($variables['theme_hook_suggestions'], array('region__sidebar')); | |
136 //} | |
137 } | |
138 // */ | |
139 | |
140 /** | |
141 * Override or insert variables into the block templates. | |
142 * | |
143 * @param $variables | |
144 * An array of variables to pass to the theme template. | |
145 * @param $hook | |
146 * The name of the template being rendered ("block" in this case.) | |
147 */ | |
148 | |
149 function mpiwgzen_wide_preprocess_block(&$variables, $hook) { | |
150 // Add a count to all the blocks in the region. | |
151 // $variables['classes_array'][] = 'count-' . $variables['block_id']; | |
152 | |
153 // By default, Zen will use the block--no-wrapper.tpl.php for the main | |
154 // content. This optional bit of code undoes that: | |
155 //if ($variables['block_html_id'] == 'block-system-main') { | |
156 // $variables['theme_hook_suggestions'] = array_diff($variables['theme_hook_suggestions'], array('block__no_wrapper')); | |
157 //} | |
158 } | |
159 | |
160 /** | |
161 * Add placeholders for forms | |
162 */ | |
163 | |
164 function mpiwgzen_wide_form_alter( &$form, &$form_state, $form_id ) | |
165 { | |
166 // Username and Password in user login form | |
167 if (in_array( $form_id, array( 'user_login', 'user_login_block'))) | |
168 { | |
169 $form['name']['#attributes']['placeholder'] = t( 'username' ); | |
170 $form['pass']['#attributes']['placeholder'] = t( 'password' ); | |
171 } | |
172 // search | |
173 // if ($form_id == 'search_block_form') | |
174 // { | |
175 // $form['search_block_form']['#attributes']['placeholder'] = t('Search...'); | |
176 // } | |
177 } | |
178 | |
179 | |
180 | |
181 // */ |