affiachage resosurces

This commit is contained in:
2025-05-27 12:05:18 +02:00
parent 727f3f18d4
commit 3ea33a596b
5 changed files with 73 additions and 32 deletions
+11 -8
View File
@@ -146,15 +146,18 @@ function eql_preprocess_layout__threecol_25_50_25(&$variables) {
if ($node->hasField('field_type_de_ressource') && !$node->get('field_type_de_ressource')->isEmpty()) {
$terms = $node->get('field_type_de_ressource')->referencedEntities();
if (!empty($terms)) {
$label = $terms[0]->label();
$css_class = 'type-' . Html::cleanCssIdentifier(strtolower($label));
// Appliquer cette classe à la région "top"
if (!isset($variables['region_attributes']['top'])) {
$variables['region_attributes']['top'] = new \Drupal\Core\Template\Attribute();
foreach ($terms as $term) {
if ($term instanceof \Drupal\taxonomy\Entity\Term) {
$label = $term->label();
$css_class = 'type-' . \Drupal\Component\Utility\Html::cleanCssIdentifier(strtolower($label));
if (!isset($variables['region_attributes']['top'])) {
$variables['region_attributes']['top'] = new \Drupal\Core\Template\Attribute();
}
$variables['region_attributes']['top']->addClass($css_class);
}
}
$variables['region_attributes']['top']->addClass($css_class);
}
}
}