template suggestions fix

This commit is contained in:
Bachir Soussi Chiadmi 2024-04-26 17:26:56 +02:00
parent 072f7da7de
commit 935fe18134
1 changed files with 29 additions and 8 deletions

View File

@ -65,17 +65,35 @@ function erabletheme_preprocess_views_view(&$variables) {
/* fonctionne mais meilleure méthode avec les suggestions page--xxx */
function erabletheme_theme_suggestions_views_view_alter(array &$suggestions, array $variables) {
if ($variables['title'] !== "") {
$view = $variables['title']['#markup'];
if (isset($view) && $view === 'Actualités') {
// il ne faut pas baser le template sur des contenus !
// if ($variables['title'] !== "") {
// $view_title = $variables['title']['#markup'];
// if (isset($view_title) && $view_title === 'Actualités') {
// $suggestions[] = 'views_view__page_actus';
// } elseif (isset($view_title) && $view_title === 'Gouvernance') {
// $suggestions[] = 'views_view__content_gouvernance';
// } elseif (isset($view_title) && $view_title === 'Partenaires') {
// $suggestions[] = 'views_view__content_partenaires';
// }
// elseif (isset($view) && $view === 'Meetup en ligne') {
// $suggestions[] = 'views_view__content_meetup';
// }
// }
$view = $variables['view'];
switch ($view->id()) {
case 'actus':
$suggestions[] = 'views_view__page_actus';
} elseif (isset($view) && $view === 'Gouvernance') {
break;
case 'gouvernance':
$suggestions[] = 'views_view__content_gouvernance';
} elseif (isset($view) && $view === 'Partenaires') {
break;
case 'partenaires':
$suggestions[] = 'views_view__content_partenaires';
} elseif (isset($view) && $view === 'Meetup en ligne') {
break;
case 'meetup':
$suggestions[] = 'views_view__content_meetup';
}
break;
}
}
@ -96,7 +114,10 @@ function erabletheme_theme_suggestions_node_alter(array &$suggestions, array $va
}
function erabletheme_theme_suggestions_region_alter(array &$suggestions, array $variables) {
if (isset($variables['elements']['erabletheme_contenudelapageprincipale']) && $variables['elements']['erabletheme_contenudelapageprincipale']['content']['#title'] == "Meet-up en ligne") {
// if (isset($variables['elements']['erabletheme_contenudelapageprincipale']) && $variables['elements']['erabletheme_contenudelapageprincipale']['content']['#title'] == "Meet-up en ligne") {
// il ne faut pas baser le template sur des contenus !
if (isset($variables['elements']['erabletheme_contenudelapageprincipale'])
&& $variables['elements']['erabletheme_contenudelapageprincipale']['content']['#view_id'] == "meetup") {
$suggestions[] = 'region__offre_meetup';
} elseif (isset($variables['elements']['erabletheme_contenudelapageprincipale']) && $variables['elements']['erabletheme_contenudelapageprincipale']['content']['#title'] == "Foire aux Questions") {
$suggestions[] = 'region__faq';