Commit 4267cfd6 authored by Andrii Podanenko's avatar Andrii Podanenko Committed by Andrii Podanenko
Browse files

Issue #3305569 by podarok, Anchal_gupta, plato1123: Add current page path as a...

Issue #3305569 by podarok, Anchal_gupta, plato1123: Add current page path as a class to body tag (code included)
parent 9d65e893
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -28,6 +28,13 @@ function openy_carnation_preprocess_html(array &$variables) {
    ->getActiveTheme()
    ->getName();
    
  // Get the current path
  $current_path = \Drupal::service('path.current')->getPath();
  $internal_path = \Drupal::service('path_alias.manager')->getAliasByPath($current_path);

  // Assign it to body class 
  $variables['attributes']['class'][] = str_replace("/", "", $internal_path);

  // Preprocess the node to find all paragraphs and react on them.
  if (!empty($variables['node_type'])) {
    /** @var \Drupal\node\Entity\Node $node */