This repository was archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathucb2021_base.theme
More file actions
executable file
·142 lines (126 loc) · 5.55 KB
/
Copy pathucb2021_base.theme
File metadata and controls
executable file
·142 lines (126 loc) · 5.55 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
<?php
use Drupal\Core\Entity\ContentEntityBase;
/**
* @file
* Functions to support the UCB Base 2019 theme.
*/
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function ucb2021_base_theme_suggestions_page_alter(array &$suggestions, array $variables) {
if ($node = \Drupal::routeMatch()->getParameter('node')) {
$content_type = $node->bundle();
$suggestions[] = 'page__'.$content_type;
}
}
/***
* This a helper function to set the favicon appropriately
*/
function ucb2021_base_page_attachments_alter(array &$page) {
foreach($page['#attached']['html_head_link'] as $k => $v) {
if (array_key_exists('rel', $v[0]) && $v[0]['rel'] == 'shortcut icon') {
$page['#attached']['html_head_link'][$k][0]['href'] = base_path() . \Drupal::service('extension.list.theme')->getPath('ucb2021_base') . '/favicon.png';
}
}
}
/***
* Preprocess function to get the variables we'll need on the html template
*/
function ucb2021_base_preprocess_html(array &$variables) {
$variables['ucb_gtm_account'] = theme_get_setting('ucb_gtm_account');
$variables['theme_path'] = base_path() . $variables['directory'];
}
/***
* Preprocess function to get the variables we'll need on the block template
*/
function ucb2021_base_preprocess_block(array &$variables) {
$config = \Drupal::config('system.site');
$variables['site_name'] = $config->get('name');
}
/***
* Preprocess function to get the variables we'll need on the page template
*/
function ucb2021_base_preprocess_page(array &$variables) {
$config = \Drupal::config('system.site');
$variables['site_name'] = $config->get('name');
$variables['site_slogan'] = $config->get('slogan');
$variables['ucb_secondary_menu'] = theme_get_setting('ucb_secondary_menu');
$variables['ucb_footer_menu'] = theme_get_setting('ucb_footer_menu');
$variables['theme_path'] = base_path() . $variables['directory'];
$variables['ucb_campus_header_color'] = theme_get_setting('ucb_campus_header_color');
$variables['ucb_header_color'] = theme_get_setting('ucb_header_color');
$variables['ucb_be_boulder'] = theme_get_setting('ucb_be_boulder');
$variables['ucb_social_share_position'] = theme_get_setting('ucb_social_share_position');
$variables['ucb_rave_alerts'] = theme_get_setting('ucb_rave_alerts');
// check to see if we're on the homepage or not
try {
$variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage();
}
catch (Exception $e) {
$variables['is_front'] = FALSE;
}
}
/***
* Preprocess function to get the variables we'll need on the page user template
*/
function ucb2021_base_preprocess_page__user(array &$variables) {
$config = \Drupal::config('system.site');
$variables['site_name'] = $config->get('name');
$variables['site_slogan'] = $config->get('slogan');
$variables['ucb_secondary_menu'] = theme_get_setting('ucb_secondary_menu');
$variables['ucb_footer_menu'] = theme_get_setting('ucb_footer_menu');
$variables['theme_path'] = base_path() . $variables['directory'];
$variables['ucb_campus_header_color'] = theme_get_setting('ucb_campus_header_color');
$variables['ucb_header_color'] = theme_get_setting('ucb_header_color');
$variables['ucb_be_boulder'] = theme_get_setting('ucb_be_boulder');
}
/***
* Preprocess function to get the variables we'll need on the page user login template
*/
function ucb2021_base_preprocess_page__user__login(array &$variables) {
$config = \Drupal::config('system.site');
$variables['site_name'] = $config->get('name');
$variables['site_slogan'] = $config->get('slogan');
$variables['ucb_secondary_menu'] = theme_get_setting('ucb_secondary_menu');
$variables['ucb_footer_menu'] = theme_get_setting('ucb_footer_menu');
$variables['theme_path'] = base_path() . $variables['directory'];
$variables['ucb_campus_header_color'] = theme_get_setting('ucb_campus_header_color');
$variables['ucb_header_color'] = theme_get_setting('ucb_header_color');
$variables['ucb_be_boulder'] = theme_get_setting('ucb_be_boulder');
}
/***
* Preprocess function to get the variables we'll need on the header region template
*/
function ucb2021_base_preprocess_region__header(array &$variables) {
$variables['theme_path'] = base_path() . $variables['directory'];
$variables['ucb_be_boulder'] = theme_get_setting('ucb_be_boulder');
}
/***
* Preprocess function to get the variables we'll need on the footer region template
*/
function ucb2021_base_preprocess_region__footer(array &$variables) {
$variables['theme_path'] = base_path() . $variables['directory'];
$variables['ucb_be_boulder'] = theme_get_setting('ucb_be_boulder');
}
/***
* preprocess function to get the variables we'll need on the Organization node template
*/
function ucb2021_base_preprocess_node__organization(array &$variables) {
$variables['uuid'] = $variables['node']->uuid();
}
/***
* Custom theme settings worker function
***/
function ucb2021_base_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id = NULL) {
// Work-around for a core bug affecting admin themes. See issue #943212.
if (isset($form_id)) {
return;
}
if(\Drupal::service('module_handler')->moduleExists('ucb_site_configuration')) {
// This call relies on the module dependency `ucb_site_configuration`.
// It uses the function `buildThemeSettingsForm` in the module to build the theme settings form.
\Drupal::service('ucb_site_configuration')->buildThemeSettingsForm($form, $form_state);
} else {
\Drupal::service('messenger')->addError('Module `CU Boulder Site Configuration`, required to display the CU Boulder theme settings form, isn\'t installed.');
}
}