-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbadcamp_theme.theme
136 lines (112 loc) · 4.06 KB
/
badcamp_theme.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
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
<?php
use Drupal\Component\Utility\Html;
use Drupal\Core\Url;
use Drupal\Core\Link;
/**
* Implements hook_form_alter().
*/
function badcamp_theme_form_mailchimp_signup_subscribe_block_stay_connected_form_alter(&$form, &$form_state) {
$form['container'] = [
'#prefix' => '<div class="inputs">',
'#suffix' => '</div>'
];
$form['mergevars']['EMAIL']['#title_display'] = 'invisible';
$form['mergevars']['EMAIL']['#attributes']['placeholder'] = 'E-mail Address';
$form['mergevars']['EMAIL']['#attributes']['aria-label'] = 'E-mail Address';
$form['mergevars']['EMAIL']['#attributes']['title'] = 'E-mail Address';
$form['container']['mergevars'] = $form['mergevars'];
$form['container']['actions'] = $form['actions']['submit'];
if (isset($form['mergevars'])) {
unset($form['mergevars']);
}
if(isset($form['actions'])) {
unset($form['actions']);
}
$form['description']['#prefix'] = '<p class="description">';
$form['description']['#suffix'] = '</p>';
}
/**
* Implements hook_preprocess_menu().
*/
function badcamp_theme_preprocess_menu__account(&$vars) {
foreach($vars['items'] AS &$item) {
// $item['attributes']
// ->addClass('button')
// ->addClass('button-rounded-hover');
}
}
/**
* Implements template_preprocess_node__node_type__node_display().
*/
function badcamp_theme_preprocess_node__sponsor__full(&$vars){
$vars['sponsor_url'] = (!empty($vars['content']['field_sponsor_url'][0]) ? $vars['content']['field_sponsor_url'][0]['#url']->getUri() : '/sponsors');
$vars['logo'] = $vars['content']['field_sponsor_logo'];
}
/**
* Implements template_preprocess_node__node_type__node_display().
*/
function badcamp_theme_preprocess_node__sponsor__sponsor_logo(&$vars){
/** @var \Drupal\node\Entity\Node $node */
$node = $vars['elements']['#node'];
$vars['can_edit'] = $node->access('update');
}
/**
* Implements template_preprocess_views_view_unformatted__view__display().
*/
function badcamp_theme_preprocess_views_view_unformatted__sponsors__page_1(&$vars){
$vars['level_class'] = HTML::cleanCssIdentifier(strtolower(strip_tags($vars['title'])));
switch($vars['level_class']){
case 'core-level':
$vars['sizing_class'] = 'small-up-1 medium-up-3';
break;
default:
$vars['sizing_class'] = 'small-up-2 medium-up-4';
break;
}
}
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function badcamp_theme_theme_suggestions_user_alter(&$suggestions, $vars){
$suggestions[] = 'user__' . $vars['elements']['#view_mode'];
}
/**
* Implements hook_theme_suggestions_field_alter().
*/
function badcamp_theme_theme_suggestions_field_alter(&$suggestions, $vars){
$suggestions[] = 'field__node__' . $vars['element']['#field_name'] . '__' . $vars['element']['#bundle'] . '__' . $vars['element']['#view_mode'];
}
/**
* Implements hook_preprocess_user().
*/
function badcamp_theme_preprocess_user(&$vars) {
$vars['org_url'] = (!empty($vars['content']['field_organization_url'][0]) ? $vars['content']['field_organization_url'][0]['#url']->toString() : '');
/** @var User $account */
$account = $vars['elements']['#user'];
$vars['username'] = $account->getDisplayName();
}
/**
* Implements hook_preprocess_html().
*/
function badcamp_theme_preprocess_html(array &$variables) {
// Add body classes for node add/edit forms.
$route_name = \Drupal::routeMatch()->getRouteName();
if ($route_name == 'entity.node.edit_form') {
$variables['attributes']['class'][] = 'node-edit';
}
if ($route_name == 'node.add') {
$variables['attributes']['class'][] = 'node-add';
}
// Add nid to body class.
if ($node = \Drupal::request()->attributes->get('node')) {
$variables['attributes']['class'][] = 'page-node--' . $node->id();
}
}
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function badcamp_theme_theme_suggestions_form_element_alter(&$suggestions, $vars){
$name = trim(str_ireplace(['[',']','-'], '_', $vars['element']['#name']), '_');
$suggestions[] = 'form_element__' . $vars['element']['#type'];
$suggestions[] = 'form_element__' . $vars['element']['#type'] . '__' . $name;
}