-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwtheme.theme
36 lines (29 loc) · 1006 Bytes
/
wtheme.theme
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
<?php
/**
* @file
* Functions to support theming in the wtheme theme.
*/
/**
* Implements template_preprocess_HOOK() for the HTML template.
*/
function wtheme_preprocess_html(&$variables) {
// Add node id as a class.
$request = \Drupal::request();
$node = ($request->attributes->get('_route') == 'entity.node.canonical' ? $request->attributes->get('node') : NULL );
if ($node) {
$variables['attributes']['class'][] = 'page-node-' . $node->id();
}
/* Add information about presence of sidebars.
.sidebar-first.sidebar-second means class for two sidebars. */
$has_first_sidebar = !empty($variables['page']['sidebar_first']);
$has_second_sidebar = !empty($variables['page']['sidebar_second']);
if ($has_first_sidebar) {
$variables['attributes']['class'][] = 'layout-sidebar-first';
}
elseif ($has_second_sidebar) {
$variables['attributes']['class'][] = 'layout-sidebar-second';
}
else {
$variables['attributes']['class'][] = 'layout-no-sidebars';
}
}