diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 723ae63..0d4dce9 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1680,24 +1680,13 @@ function template_preprocess_html(&$variables) { // type, etc.). $body_classes = $variables['attributes']['class']; - // Add a class that tells us whether the page is viewed by an authenticated - // user. - if ($variables['logged_in']) { - $body_classes[] = 'user-logged-in'; - } - // Add a class that tells us what path the page is located make it possible - // to theme the page depending on the current path (e.g. node, admin, user, - // etc.) as well as more specific data like path-frontpage. + // Add a variable that tells us what path the page is located make it possible + // to create class and theme the page depending on the current path (e.g. + // node, admin, user, etc.) as well as more specific data like + // path-frontpage. $path = \Drupal::request()->getPathInfo(); - if (drupal_is_front_page()) { - $body_classes[] = 'path-frontpage'; - } - else { - $segment = explode('/', $path); - $body_classes[] = 'path-' . drupal_html_class($segment[1]); - } - + $variables['root_path'] = explode('/', $path); $variables['attributes']['class'] = $body_classes; $site_config = \Drupal::config('system.site'); diff --git a/core/modules/system/templates/html.html.twig b/core/modules/system/templates/html.html.twig index d605532..a7d10d0 100644 --- a/core/modules/system/templates/html.html.twig +++ b/core/modules/system/templates/html.html.twig @@ -26,6 +26,12 @@ * @ingroup themeable */ #} +{% + set body_classes = [ + logged_in ? 'user-logged-in', + is_front ? 'path-frontpage' : 'path-' ~ root_path|clean_class, + ] +%}