forked from borisay/backdrop_decanter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.php
More file actions
153 lines (138 loc) · 5.09 KB
/
template.php
File metadata and controls
153 lines (138 loc) · 5.09 KB
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
<?php
/**
* @file
* backdrop_decanter preprocess functions and theme function overrides.
*/
/**
* Implements hook_css_alter().
*/
function backdrop_decanter_css_alter(&$css) {
// Remove backdrop_decanter' `/css/component/menu-dropdown.css` if using a custom
// breakpoint.
if (config_get('menu.settings', 'menu_breakpoint') == 'custom') {
$path = backdrop_get_path('theme', 'backdrop_decanter');
unset($css[$path . '/css/component/menu-dropdown.css']);
}
}
/**
* Prepares variables for page templates.
*
* @see page.tpl.php
*/
function backdrop_decanter_preprocess_page(&$variables) {
$node = menu_get_object();
//var_dump($variables[block]);
// Add the OpenSans font from core on every page of the site.
backdrop_add_library('system', 'opensans', TRUE);
// To add a class 'page-node-[nid]' to each page.
if ($node) {
$variables['classes'][] = 'page-node-' . $node->nid;
}
// To add a class 'view-name-[name]' to each page.
$view = views_get_page_view();
if ($view) {
$variables['classes'][] = 'view-name-' . $view->name;
}
// Add breakpoint-specific CSS for dropdown menus.
$config = config('menu.settings');
if ($config->get('menu_breakpoint') == 'custom') {
backdrop_add_css(backdrop_get_path('theme', 'backdrop_decanter') . '/css/component/menu-dropdown.breakpoint.css', array(
'group' => CSS_THEME,
'every_page' => TRUE,
));
backdrop_add_css(backdrop_get_path('theme', 'backdrop_decanter') . '/css/component/menu-dropdown.breakpoint-queries.css', array(
'group' => CSS_THEME,
'every_page' => TRUE,
'media' => 'all and (min-width: ' . $config->get('menu_breakpoint_custom') . ')',
));
}
// add class su-main-nav
// backdrop_add_js('(function($) { $(".su-secondary-nav__menu ul li.active-trail").addClass("su-secondary-nav__item--current");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
}
/**
* Prepares variables for maintenance page templates.
*
* @see maintenance-page.tpl.php
*/
function backdrop_decanter_preprocess_maintenance_page(&$variables) {
$css_path = backdrop_get_path('theme', 'backdrop_decanter') . '/css/component/maintenance.css';
backdrop_add_css($css_path);
}
/**
* Prepares variables for layout templates.
*
* @see layout.tpl.php
*/
function backdrop_decanter_preprocess_layout(&$variables) {
if ($variables['is_front']) {
// Add a special front-page class.
$variables['classes'][] = 'layout-front';
// Add a special front-page template suggestion.
$original = $variables['theme_hook_original'];
$variables['theme_hook_suggestions'][] = $original . '__front';
$variables['theme_hook_suggestion'] = $original . '__front';
}
// Default Backdrop layouts contain both .container and .container-fluid.
backdrop_add_js('(function($) { $(".l-header-inner.container.container-fluid").removeClass("container-fluid").removeClass("container");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
backdrop_add_js('(function($) { $(".l-wrapper-inner.container.container-fluid").removeClass("container-fluid");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
backdrop_add_js('(function($) { $(".l-footer-inner.container.container-fluid").removeClass("container");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
}
/**
* Prepares variables for node templates.
*
* @see node.tpl.php
*/
function backdrop_decanter_preprocess_node(&$variables) {
if ($variables['status'] == NODE_NOT_PUBLISHED) {
$name = node_type_get_name($variables['type']);
$variables['title_suffix']['unpublished_indicator'] = array(
'#type' => 'markup',
'#markup' => '<div class="unpublished-indicator">' . t('This @type is unpublished.', array('@type' => $name)) . '</div>',
);
}
}
/**
* Prepares variables for header templates.
*
* @see header.tpl.php
*/
function backdrop_decanter_preprocess_header(&$variables) {
$logo = $variables['logo'];
$logo_attributes = $variables['logo_attributes'];
// Add classes and height/width to logo.
if ($logo) {
$logo_wrapper_classes = array();
$logo_wrapper_classes[] = 'header-logo-wrapper';
if ($logo_attributes['width'] <= $logo_attributes['height']) {
$logo_wrapper_classes[] = 'header-logo-tall';
}
$variables['logo_wrapper_classes'] = $logo_wrapper_classes;
}
}
/**
* Overrides theme_breadcrumb(). Removes » from markup.
*
* @see theme_breadcrumb().
*/
function backdrop_decanter_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
$output = '';
if (!empty($breadcrumb)) {
$output .= '<nav class="breadcrumb">';
// Provide a navigational heading to give context for breadcrumb links to
// screen-reader users. Make the heading invisible with .element-invisible.
$output .= '<h2 class="element-invisible">' . t('You are here') . '</h2>';
$output .= '<ol><li>' . implode('</li><li>', $breadcrumb) . '</li></ol>';
$output .= '</nav>';
}
return $output;
}
/**
* Prepares variables for block templates.
*
* @see block.tpl.php
*/
function backdrop_decanter_preprocess_block(&$variables) {
if($variables['attributes']){
}
}