Sfoglia il codice sorgente

added node type and id in body classes

bach 3 anni fa
parent
commit
2b1d92fe2c
1 ha cambiato i file con 8 aggiunte e 0 eliminazioni
  1. 8 0
      web/themes/custom/eql/eql.theme

+ 8 - 0
web/themes/custom/eql/eql.theme

@@ -9,6 +9,14 @@
 // use Drupal\Core\Url;
 
 
+function eql_preprocess_html(&$variables) {
+  $node = \Drupal::routeMatch()->getParameter('node');
+  if ($node){
+    $variables['attributes']['class'][] = 'node-type-' . $node->bundle();
+    $variables['attributes']['class'][] = 'node-id-' . $node->id();
+  }
+}
+
 function eql_preprocess_node(&$variables){
   $node = &$variables['node'];
   $variables['attributes']['class'][] = 'node-type-' . $node->gettype();