Untitled
unknown
plain_text
a year ago
492 B
4
Indexable
/** * Implements hook_preprocess_HOOK() for node.html.twig. */ function your_theme_name_preprocess_node(array &$variables) { // Get the current path alias. $alias = \Drupal::service('path_alias.manager')->getAliasByPath('/node/' . $variables['node']->id()); // Clean the alias to be suitable as a CSS class. $alias_class = str_replace('/', '-', trim($alias, '/')); // Add the alias class to the node attributes. $variables['attributes']['class'][] = 'alias-' . $alias_class; }
Editor is loading...
Leave a Comment