theming: added classes to node

This commit is contained in:
2021-11-11 17:42:07 +01:00
parent c478e95f5a
commit b2fa94a657
2 changed files with 118 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
<?php
/*
* @files
* Theme Template Funtions
*/
// use Drupal\Core\Template\Attribute;
// use Drupal\Core\Link;
// use Drupal\Core\Url;
function eql_preprocess_node(&$variables){
$node = &$variables['node'];
$variables['attributes']['class'][] = 'node-type-' . $node->gettype();
if($node->gettype() == "actualite") {
$actu_type = $node->get('field_actu_type')->getString();
$variables['attributes']['class'][] = 'actu-type-' . $actu_type;
}
}