-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtweme.theme
85 lines (75 loc) · 2.36 KB
/
tweme.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
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
<?php
/**
* Prepares variables for `html.html.twig`.
*/
function tweme_preprocess_html(&$variables) {
$variables['attributes']['class'][] = 'container';
}
/**
* Prepares variables for `region.html.twig`.
*/
function tweme_preprocess_region(&$variables) {
$variables['attributes']['class'][] = 'mb-3';
}
function tweme_preprocess_region__primary_menu(&$variables) {
$variables['attributes']['class'][] = 'navbar navbar-toggleable-md navbar-light bg-faded';
}
function tweme_preprocess_region__footer(&$variables) {
$variables['attributes']['class'][] = 'card-group';
}
/**
* Prepares variables for `block.html.twig`.
*/
function tweme_preprocess_block(&$variables) {
$block = \Drupal\block\Entity\Block::load($variables['elements']['#id']);
if ($block->getRegion() == 'footer') {
$variables['attributes']['class'][] = 'card card-footer';
}
switch ($variables['elements']['#plugin_id']) {
case 'system_menu_block:main':
$variables['attributes']['class'][] = 'mr-auto';
break;
}
}
/**
* Prepares variables for `menu.html.twig`.
*/
function tweme_preprocess_menu(&$variables) {
$menu_name = isset($variables['menu_name']) ? $variables['menu_name'] : '';
switch ($menu_name) {
case 'main':
case 'account':
$variables['attributes']['class'][] = 'navbar-nav nav';
foreach ($variables['items'] as &$item) {
$item['attributes']->addClass('nav-item');
$attrs = $item['url']->getOption('attributes');
$attrs['class'][] = 'nav-link';
$item['url']->setOption('attributes', $attrs);
}
break;
default:
$variables['attributes']['class'][] = 'list-unstyled mb-0';
break;
}
}
/**
* Prepares variables for `menu-local-task.html.twig`.
*/
function tweme_preprocess_menu_local_task(&$variables) {
$variables['attributes']['class'][] = 'nav-item';
$variables['link']['#options']['attributes']['class'][] = 'nav-link' . (!empty($variables['is_active']) ? ' active' : '');
}
/**
* Prepares variables for `form.html.twig`.
*/
function tweme_preprocess_form(&$variables) {
if ($variables['element']['#form_id'] == 'search_block_form') {
$variables['attributes']['class'][] = 'container-inline';
}
}
/**
* Prepares variables for `status-messages.html.twig`.
*/
function tweme_preprocess_status_messages(&$variables) {
$variables['attributes']['class'][] = 'alert alert-info';
}