affiachage resosurces
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user