You are here

function bartik_preprocess_html in Drupal 9

Same name and namespace in other branches
  1. 8 core/themes/bartik/bartik.theme \bartik_preprocess_html()
  2. 7 themes/bartik/template.php \bartik_preprocess_html()

Implements hook_preprocess_HOOK() for HTML document templates.

Adds body classes if certain regions have content.

File

core/themes/bartik/bartik.theme, line 18
Functions to support theming in the Bartik theme.

Code

function bartik_preprocess_html(&$variables) {

  // Add information about the number of sidebars.
  if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
    $variables['attributes']['class'][] = 'layout-two-sidebars';
  }
  elseif (!empty($variables['page']['sidebar_first'])) {
    $variables['attributes']['class'][] = 'layout-one-sidebar';
    $variables['attributes']['class'][] = 'layout-sidebar-first';
  }
  elseif (!empty($variables['page']['sidebar_second'])) {
    $variables['attributes']['class'][] = 'layout-one-sidebar';
    $variables['attributes']['class'][] = 'layout-sidebar-second';
  }
  else {
    $variables['attributes']['class'][] = 'layout-no-sidebars';
  }
  if (!empty($variables['page']['featured_top'])) {
    $variables['attributes']['class'][] = 'has-featured-top';
  }
}