class type-media sur body et position block third

This commit is contained in:
2025-05-28 00:47:58 +02:00
parent 6d28a754ae
commit 41ce75a630
3 changed files with 176 additions and 168 deletions
+7 -3
View File
@@ -5785,9 +5785,13 @@ content .page-node-type-ressource .type-les-projets-en-images.layout__region--to
.page-node-type-ressource .type-les-projets-en-images.layout__region--top .block-region-top .block-entity-fieldnodefield-images .field__items { .page-node-type-ressource .type-les-projets-en-images.layout__region--top .block-region-top .block-entity-fieldnodefield-images .field__items {
display: none; display: none;
} }
.page-node-type-ressource.block-region-third .block-entity-fieldnodefield-liens,
.page-node-type-ressource.block-region-third .block-entity-fieldnodefield-projets-liee, body.type-media-reportage-photos .block-region-third .block-entity-fieldnodefield-liens,
.page-node-type-ressource.block-region-third .block-entity-fieldnodefield-fichiers { body.type-media-reportage-photos .block-region-third .block-entity-fieldnodefield-projets-liee,
body.type-media-reportage-photos .block-region-third .block-entity-fieldnodefield-fichiers,
body.type-media-vidéos .block-region-third .block-entity-fieldnodefield-liens,
body.type-media-vidéos .block-region-third .block-entity-fieldnodefield-projets-liee,
body.type-media-vidéos .block-region-third .block-entity-fieldnodefield-fichiers {
transform: translateY(-45.5rem); transform: translateY(-45.5rem);
} }
+15 -9
View File
@@ -11,27 +11,33 @@ use Drupal\Component\Utility\Html;
use Drupal\Component\Transliteration\TransliterationInterface; use Drupal\Component\Transliteration\TransliterationInterface;
use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Term;
use Drupal\Core\Template\Attribute; use Drupal\Core\Template\Attribute;
use Drupal\node\NodeInterface;
function eql_preprocess_html(&$variables) { function eql_preprocess_html(&$variables) {
$node = \Drupal::routeMatch()->getParameter('node'); $node = \Drupal::routeMatch()->getParameter('node');
if ($node){
$variables['attributes']['class'][] = 'node-type-' . $node->bundle(); if ($node instanceof \Drupal\node\NodeInterface) {
$variables['attributes']['class'][] = 'node-id-' . $node->id();
}
if ($node instanceof NodeInterface) {
$variables['attributes']['class'][] = 'node-type-' . $node->bundle(); $variables['attributes']['class'][] = 'node-type-' . $node->bundle();
$variables['attributes']['class'][] = 'node-id-' . $node->id(); $variables['attributes']['class'][] = 'node-id-' . $node->id();
// Pour les ressources : ajoute la classe de type de ressource // Liste des champs à traiter pour générer des classes dynamiques
if ($node->bundle() === 'ressource' && $node->hasField('field_type_de_ressource')) { $fields_to_classify = [
foreach ($node->get('field_type_de_ressource')->referencedEntities() as $term) { 'field_type_de_ressource' => 'type-',
'field_type_de_media' => 'type-media-',
];
foreach ($fields_to_classify as $field_name => $prefix) {
if ($node->hasField($field_name) && !$node->get($field_name)->isEmpty()) {
foreach ($node->get($field_name)->referencedEntities() as $term) {
$label = $term->label(); $label = $term->label();
$css_class = 'type-' . Html::getClass($label); $css_class = $prefix . Html::cleanCssIdentifier(strtolower($label));
$variables['attributes']['class'][] = $css_class; $variables['attributes']['class'][] = $css_class;
} }
} }
} }
} }
}
function eql_preprocess_node(&$variables){ function eql_preprocess_node(&$variables){
@@ -1,6 +1,5 @@
.carousel{display: none;} .carousel{display: none;}
.page-node-type-ressource{ .page-node-type-ressource{
.type-les-projets-en-images.layout__region--top{ .type-les-projets-en-images.layout__region--top{
.block-region-top{ .block-region-top{
display: flex !important; display: flex !important;
@@ -16,7 +15,6 @@
margin-top: 5rem; margin-top: 5rem;
padding: 0; padding: 0;
order: 7; order: 7;
.carousel { .carousel {
display: block; display: block;
max-width: 60vw; max-width: 60vw;
@@ -138,7 +136,6 @@
} }
} }
} }
// Masquer les images Drupal originales (facultatif) // Masquer les images Drupal originales (facultatif)
.field__items { .field__items {
display: none; display: none;
@@ -146,16 +143,17 @@
} }
} }
} }
&.block-region-third{ }
body.type-media-reportage-photos,
body.type-media-vidéos{
.block-region-third{
.block-entity-fieldnodefield-liens, .block-entity-fieldnodefield-liens,
.block-entity-fieldnodefield-projets-liee, .block-entity-fieldnodefield-projets-liee,
.block-entity-fieldnodefield-fichiers{ .block-entity-fieldnodefield-fichiers{
transform: translateY(-45.5rem); transform: translateY(-45.5rem);
} }
}
} }
}