nordicmaterial2
10/13/2016 - 9:04 AM

Add body classes to your theme:

Add body classes to your theme:

{# Edit the file mijnthema.theme #}
{# WITHIN the function musethema_preprocess_html(&$variables), add these lines #}

  // Nordic: get language global variables

  $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
  $variables['language'] = $language;


{# Add this code to the file html.html.twig #}
{# This declaration comes before the <!DOCTYPE html> line: #}

{%
  set body_classes = [
    logged_in ? 'user-logged-in',
    not root_path ? 'path-frontpage' : 'path-' ~ root_path|clean_class,
    node_type ? 'page-node-type-' ~ node_type|clean_class,
    language ? 'lang-' ~ language|clean_class,
    db_offline ? 'db-offline',
    page.sidebar_first ? 'sidebar-first',
    page.sidebar_second ? 'sidebar-second',
  ]
%}

{# This replaces the <body> tag: #}

 <body{{ attributes.addClass(body_classes) }}>