-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.php
129 lines (115 loc) · 3.53 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
<?php
/**
* @file
* HTML template functions.
*/
/**
* Implements hook_preprocess_html().
* Meta tags https://drupal.org/node/1468582#comment-5698732
*/
function sonambulo_preprocess_html(&$variables) {
$meta_charset = array(
'#tag' => 'meta',
'#attributes' => array(
'charset' => 'utf-8',
),
);
drupal_add_html_head($meta_charset, 'meta_charset');
$meta_x_ua_compatible = array(
'#tag' => 'meta',
'#attributes' => array(
'http-equiv' => 'x-ua-compatible',
'content' => 'ie=edge, chrome=1',
),
);
drupal_add_html_head($meta_x_ua_compatible, 'meta_x_ua_compatible');
$meta_mobile_optimized = array(
'#tag' => 'meta',
'#attributes' => array(
'name' => 'MobileOptimized',
'content' => 'width',
),
);
drupal_add_html_head($meta_mobile_optimized, 'meta_mobile_optimized');
$meta_handheld_friendly = array(
'#tag' => 'meta',
'#attributes' => array(
'name' => 'HandheldFriendly',
'content' => 'true',
),
);
drupal_add_html_head($meta_handheld_friendly, 'meta_handheld_friendly');
$meta_viewport = array(
'#tag' => 'meta',
'#attributes' => array(
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1',
),
);
drupal_add_html_head($meta_viewport, 'meta_viewport');
$meta_cleartype = array(
'#tag' => 'meta',
'#attributes' => array(
'http-equiv' => 'cleartype',
'content' => 'on',
),
);
drupal_add_html_head($meta_cleartype, 'meta_cleartype');
// Use html5shiv.
if (theme_get_setting('html5shim')) {
$element = array(
'element' => array(
'#tag' => 'script',
'#value' => '',
'#attributes' => array(
'type' => 'text/javascript',
'src' => file_create_url(drupal_get_path('theme', 'sonambulo') . '/js/html5shiv-printshiv.js'),
),
),
);
$html5shim = array(
'#type' => 'markup',
'#markup' => "<!--[if lt IE 9]>\n" . theme('html_tag', $element) . "<![endif]-->\n",
);
drupal_add_html_head($html5shim, 'sonambulo_html5shim');
}
// Use Respond.js.
if (theme_get_setting('respond_js')) {
drupal_add_js(drupal_get_path('theme', 'sonambulo') . '/js/respond.min.js', array('group' => JS_LIBRARY, 'weight' => -100));
}
// Use normalize.css
if (theme_get_setting('normalize_css')) {
drupal_add_css(drupal_get_path('theme', 'sonambulo') . '/css/normalize.css', array('group' => CSS_SYSTEM, 'weight' => -100));
}
}
/**
* Implements hook_html_head_alter().
*/
function sonambulo_html_head_alter(&$head_elements) {
// Remove system content type meta tag.
unset($head_elements['system_meta_content_type']);
}
/**
* Implements hook_page_alter().
* https://gist.github.com/jacine/1378246
*/
function sonambulo_page_alter(&$page) {
// Remove all the region wrappers.
foreach (element_children($page) as $key => $region) {
if (!empty($page[$region]['#theme_wrappers'])) {
$page[$region]['#theme_wrappers'] = array_diff($page[$region]['#theme_wrappers'], array('region'));
}
}
// Remove the wrapper from the main content block.
if (!empty($page['content']['system_main'])) {
$page['content']['system_main']['#theme_wrappers'] = array_diff($page['content']['system_main']['#theme_wrappers'], array('block'));
}
}
function sonambulo_preprocess_node(&$vars) {
// Add a striping class.
$vars['classes_array'][] = 'node-' . $vars['zebra'];
}
function sonambulo_preprocess_block(&$vars, $hook) {
// Add a striping class.
$vars['classes_array'][] = 'block-' . $vars['zebra'];
}