-
Notifications
You must be signed in to change notification settings - Fork 2
/
york_drupal_theme.theme
92 lines (82 loc) · 3.24 KB
/
york_drupal_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
<?php
/**
* @file
* Functions to support theming in the SASS Starterkit subtheme.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_system_theme_settings_alter() for settings form.
*
* Replace Barrio setting options with subtheme ones.
*
* Example on how to alter theme settings form
*/
function york_drupal_theme_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) {
$form['components']['navbar']['bootstrap_barrio_navbar_top_background']['#options'] = [
'bg-primary' => t('Primary'),
'bg-secondary' => t('Secondary'),
'bg-light' => t('Light'),
'bg-dark' => t('Dark'),
'bg-white' => t('White'),
'bg-transparent' => t('Transparent'),
];
$form['components']['navbar']['bootstrap_barrio_navbar_background']['#options'] = [
'bg-primary' => t('Primary'),
'bg-secondary' => t('Secondary'),
'bg-light' => t('Light'),
'bg-dark' => t('Dark'),
'bg-white' => t('White'),
'bg-transparent' => t('Transparent'),
];
}
/**
* Implements hook_form_FORM_ID_alter().
* function york_drupal_theme_form_views_exposed_form_alter(&$form, &$form_state) {
* Targeted Form: views-exposed-form-solr-search-content-page-1
*/
function york_drupal_theme_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form['#id'] == 'views-exposed-form-solr-search-content-page-1') {
if (isset($form['search_api_fulltext']) && $form['search_api_fulltext']['#type'] == 'textfield') {
$form['search_api_fulltext'] = array(
'#type' => 'textfield',
// This is the placeholder, the text inside the textfield.
'#attributes' => array(
'placeholder' => t('Search York University Digital Library')
// 'class' => array('form-control form-control-lg rounded-0 ')
),
);
$form['actions']['submit']['#attributes']['class'][] = 'btn-primary';
}
}
}
/**
* Implements hook_preprocess_field().
*/
function york_drupal_theme_preprocess_field(&$variables) {
$base_path = \Drupal::request()->getSchemeAndHttpHost();
if ($variables['element']['#field_name'] == 'field_rights') {
foreach ($variables['element']['#items'] as $key => $items) {
$entity = $items->entity;
if(!empty($entity)){
$image_url = $entity->get('field_image_url_')->uri;
$alt_text = isset($variables['element'][$key]["#title"]) ? $variables['element'][$key]["#title"] : "";
$term_path = $entity->get('path')->alias;
$image = '<p><a href="'. $base_path . $term_path.'"><img class="p-1 bg-black copy_right" src="' . $image_url . '" alt="'. $alt_text.'" /></a></p>';
$variables['items'][$key]['content'] = ['#markup' => $image];
}
}
}
}
/**
* Implements hook_preprocess_taxonomy_term().
*/
function york_drupal_theme_preprocess_taxonomy_term(&$variables) {
$term = $variables['term'];
$taxonomy_term = $variables["elements"]["#taxonomy_term"];
if ($term->hasField('field_image_url_')){
$alt_text = $taxonomy_term->hasField('name') ? $taxonomy_term->get('name')->value : "";
$image_url = $term->get('field_image_url_')->uri;
$image = '<img class="p-1 bg-black copy_right" src="' . $image_url . '" alt="'. $alt_text.'">';
$variables['content'][0] = ['#markup' => $image];
}
}