i have this code to include node-ID attributes to the body tag on the page. My question is ... how can i modify this code to get additional dynamic attributes for the BODY class? The most important for me are classes for the current vocabulary and taxonomy term, possibly a panel page.. I has been searching for few days and found only solution for node-ID.
Thank you many times for help.
/**
* Implements hook_preprocess_html().
*/
function enar_preprocess_html(&$variables) {
$node = \Drupal::request()->attributes->get('node');
if ($node) {
$variables['attributes']['class'][] = 'page-node-' . $node->id();
if (empty($node->get('body')->value)) {
$variables['attributes']['class'][] = 'no-padding-main-content';
}
}
// Don't display the site name twice on the front page (and potentially others)
if (isset($variables['head_title_array']['title']) && isset($variables['head_title_array']['name']) && ($variables['head_title_array']['title'] == $variables['head_title_array']['name'])) {
$variables['head_title'] = $variables['head_title_array']['name'];
}
// Preloader configuration
$preloader = theme_get_setting('preloader');
$variables['attributes']['class'][] = $preloader;
$variables['preloader'] = $preloader;
// Go to top configuration
$goto = theme_get_setting('gototop');
$variables['goto'] = $goto;
}