function UmamiHooks::preprocessHtml
Same name and namespace in other branches
- main core/profiles/demo_umami/themes/umami/src/Hook/UmamiHooks.php \Drupal\umami\Hook\UmamiHooks::preprocessHtml()
Implements hook_preprocess_HOOK() for html.
Adds body classes if certain regions have content.
Attributes
#[Hook('preprocess_html')]
File
-
core/
profiles/ demo_umami/ themes/ umami/ src/ Hook/ UmamiHooks.php, line 25
Class
- UmamiHooks
- Hook implementations for umami.
Namespace
Drupal\umami\HookCode
public function preprocessHtml(&$variables) : void {
// Add a sidebar class if the sidebar has content in it.
if (!empty($variables['page']['sidebar'])) {
$variables['attributes']['class'][] = 'two-columns';
$variables['#attached']['library'][] = 'umami/two-columns';
}
else {
$variables['attributes']['class'][] = 'one-column';
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.