You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
<?php |
|
|
|
/** |
|
* @file |
|
* Functions to support theming. |
|
*/ |
|
|
|
/** |
|
* Implements hook_preprocess_html(). |
|
* |
|
* Tags <body> with a sidebar-configuration class so css/layout.css can |
|
* pick the right grid template. One of: |
|
* - layout-no-sidebars |
|
* - layout-one-sidebar + layout-sidebar-first (only sidebar_first has content) |
|
* - layout-one-sidebar + layout-sidebar-second (only sidebar_second has content) |
|
* - layout-two-sidebars |
|
*/ |
|
function druid_preprocess_html(array &$variables): void { |
|
$has_first = !empty($variables['page']['sidebar_first']); |
|
$has_second = !empty($variables['page']['sidebar_second']); |
|
|
|
if ($has_first && $has_second) { |
|
$variables['attributes']['class'][] = 'layout-two-sidebars'; |
|
} |
|
elseif ($has_first) { |
|
$variables['attributes']['class'][] = 'layout-one-sidebar'; |
|
$variables['attributes']['class'][] = 'layout-sidebar-first'; |
|
} |
|
elseif ($has_second) { |
|
$variables['attributes']['class'][] = 'layout-one-sidebar'; |
|
$variables['attributes']['class'][] = 'layout-sidebar-second'; |
|
} |
|
else { |
|
$variables['attributes']['class'][] = 'layout-no-sidebars'; |
|
} |
|
} |
|
|
|
/** |
|
* Implements hook_preprocess_image_widget(). |
|
*/ |
|
function druid_preprocess_image_widget(array &$variables): void { |
|
$data = &$variables['data']; |
|
|
|
// This prevents image widget templates from rendering preview container HTML |
|
// to users that do not have permission to access these previews. |
|
// @todo revisit in https://drupal.org/node/953034 |
|
// @todo revisit in https://drupal.org/node/3114318 |
|
if (isset($data['preview']['#access']) && $data['preview']['#access'] === FALSE) { |
|
unset($data['preview']); |
|
} |
|
}
|
|
|