application de la nouvelle identité sur toutes les pages
This commit is contained in:
@@ -27,6 +27,27 @@ function erabletheme_preprocess_node(&$variables) {
|
||||
$date_formatter = \Drupal::service('date.formatter');
|
||||
$variables['date'] = $date_formatter->format($node->created->value, 'custom', 'j F Y', null, 'fr');
|
||||
}
|
||||
/**
|
||||
* Inject le label du tag courant pour les pages d'archive taxonomy
|
||||
* (rendu par node--view--taxonomy-term.html.twig).
|
||||
*/
|
||||
function erabletheme_preprocess_node__view__taxonomy_term(&$variables) {
|
||||
$route_match = \Drupal::routeMatch();
|
||||
if ($route_match->getRouteName() === 'entity.taxonomy_term.canonical') {
|
||||
$term = $route_match->getParameter('taxonomy_term');
|
||||
if ($term) {
|
||||
$variables['taxonomy_term_label'] = $term->label();
|
||||
// Le rendu du node est caché : on déclare la dépendance sur la route
|
||||
// courante (sinon tous les terms partagent la même valeur cachée).
|
||||
$variables['#cache']['contexts'][] = 'route';
|
||||
$variables['#cache']['tags'] = array_merge(
|
||||
$variables['#cache']['tags'] ?? [],
|
||||
$term->getCacheTags()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function erabletheme_preprocess_node__view__meetup(&$variables) {
|
||||
/** @var \Drupal\node\Entity $node */
|
||||
$node = $variables['node'];
|
||||
|
||||
Reference in New Issue
Block a user