diff --git a/core/includes/theme.inc b/core/includes/theme.inc index d7387a2..f8d8b7c 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1657,28 +1657,9 @@ function template_preprocess_html(&$variables) { $variables['attributes'] = $page->getBodyAttributes(); $variables['page'] = $page; - // Compile a list of classes that are going to be applied to the body element. - // This allows advanced theming based on context (home page, node of certain type, etc.). - $body_classes = $variables['attributes']['class']; - $body_classes[] = 'html'; - // Add a class that tells us whether we're on the front page or not. - $body_classes[] = $variables['is_front'] ? 'front' : 'not-front'; - // Add a class that tells us whether the page is viewed by an authenticated user or not. - $body_classes[] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in'; - $variables['attributes']['class'] = $body_classes; - $path_args = explode('/', current_path()); // Populate the body classes. - if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) { - foreach ($suggestions as $suggestion) { - if ($suggestion != 'page-front') { - // Add current suggestion to page classes to make it possible to theme - // the page depending on the current page type (e.g. node, admin, user, - // etc.) as well as more specific data like node-12 or node-edit. - $variables['attributes']['class'][] = drupal_html_class($suggestion); - } - } - } + $variables['theme_suggestions'] = theme_get_suggestions($path_args, 'page', '-'); $site_config = \Drupal::config('system.site'); // Construct page title. diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 159a230..01159cc 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -533,7 +533,7 @@ function node_is_page(NodeInterface $node) { function node_preprocess_html(&$variables) { // If on an individual node page, add the node type to body classes. if (($node = \Drupal::routeMatch()->getParameter('node')) && $node instanceof NodeInterface) { - $variables['attributes']['class'][] = drupal_html_class('node--type-' . $node->getType()); + $variables['node_type'] = $node->getType(); } } diff --git a/core/modules/system/templates/html.html.twig b/core/modules/system/templates/html.html.twig index d605532..2e15f97 100644 --- a/core/modules/system/templates/html.html.twig +++ b/core/modules/system/templates/html.html.twig @@ -27,6 +27,18 @@ */ #} +{% + set body_classes = [ + 'html', + is_front ? 'front' : 'not-front', + logged_in ? 'logged-in' : 'not-logged-in', + node_type ? 'node--type-' ~ node_type|clean_class, + ] +%} +{% set suggestion_classes = [] %} +{% for theme_suggestion in theme_suggestions if theme_suggestion != 'page-front' %} + {% set suggestion_classes = suggestion_classes|merge([theme_suggestion|clean_class]) %} +{% endfor %} {{ page.head }} @@ -34,7 +46,7 @@ {{ page.styles }} {{ page.scripts }} - +