2023-11-30 17:33:32 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Functions to support theming in the erabletheme theme.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_HOOK() for html.html.twig.
|
|
|
|
*/
|
|
|
|
function erabletheme_preprocess_html(&$variables) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_HOOK() for page.html.twig.
|
|
|
|
*/
|
|
|
|
function erabletheme_preprocess_page(&$variables) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_HOOK() for node.html.twig.
|
|
|
|
*/
|
|
|
|
function erabletheme_preprocess_node(&$variables) {
|
2023-12-13 15:08:55 +01:00
|
|
|
$t = "t";
|
2023-11-30 17:33:32 +01:00
|
|
|
}
|
2024-04-19 17:43:06 +02:00
|
|
|
function erabletheme_preprocess_node__view__meetup(&$variables) {
|
2024-04-19 17:55:01 +02:00
|
|
|
/** @var \Drupal\node\Entity $node */
|
2024-04-19 17:43:06 +02:00
|
|
|
$node = $variables['node'];
|
|
|
|
$user_id = $node->get('uid')->getValue()[0]['target_id'];
|
2024-04-19 17:55:01 +02:00
|
|
|
/** @var Drupal\user\Entity $user*/
|
2024-04-19 17:43:06 +02:00
|
|
|
$user = \Drupal\user\Entity\User::load($user_id);
|
2024-04-19 17:55:01 +02:00
|
|
|
/** @var Drupal\profile\Entity $profile */
|
2024-04-19 17:43:06 +02:00
|
|
|
$profile = $user->get('candidat' . '_profiles')->entity;
|
2024-04-19 17:55:01 +02:00
|
|
|
if ($profile) {
|
|
|
|
$variables['profile'] = [
|
|
|
|
'prenom' => $profile->get('field_prenom')->getValue()[0]['value'],
|
|
|
|
'nom' => $profile->get('field_nom')->getValue()[0]['value']
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
$variables['profile'] = [
|
|
|
|
'prenom' => $user->getAccountName(),
|
|
|
|
'nom' => "",
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-04-19 17:43:06 +02:00
|
|
|
}
|
2023-12-04 13:56:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_HOOK() for node.html.twig.
|
|
|
|
*/
|
|
|
|
function erabletheme_preprocess_form(&$variables) {
|
|
|
|
$t="t";
|
|
|
|
}
|
2023-12-06 05:01:23 +01:00
|
|
|
|
|
|
|
function erabletheme_preprocess_region(&$variables) {
|
|
|
|
$t="t";
|
2023-12-13 15:08:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function erabletheme_preprocess_views_view(&$variables) {
|
|
|
|
$t="t";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fonctionne mais meilleure méthode avec les suggestions page--xxx */
|
|
|
|
|
|
|
|
function erabletheme_theme_suggestions_views_view_alter(array &$suggestions, array $variables) {
|
2024-04-26 17:26:56 +02:00
|
|
|
// 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':
|
2023-12-13 15:08:55 +01:00
|
|
|
$suggestions[] = 'views_view__page_actus';
|
2024-04-26 17:26:56 +02:00
|
|
|
break;
|
2024-04-26 17:32:03 +02:00
|
|
|
case 'gourvernance': // attention faute de frappe dans l'id dans drupal
|
2023-12-13 15:08:55 +01:00
|
|
|
$suggestions[] = 'views_view__content_gouvernance';
|
2024-04-26 17:26:56 +02:00
|
|
|
break;
|
|
|
|
case 'partenaires':
|
2023-12-13 15:08:55 +01:00
|
|
|
$suggestions[] = 'views_view__content_partenaires';
|
2024-04-26 17:26:56 +02:00
|
|
|
break;
|
|
|
|
case 'meetup':
|
2024-03-29 21:29:59 +01:00
|
|
|
$suggestions[] = 'views_view__content_meetup';
|
2024-04-26 17:26:56 +02:00
|
|
|
break;
|
2023-12-13 15:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function erabletheme_theme_suggestions_node_alter(array &$suggestions, array $variables) {
|
|
|
|
$is_actu = isset($variables['elements']['field_type_d_actualite']);
|
|
|
|
|
|
|
|
if (!$is_actu && isset($variables['elements']['#title'])) {
|
|
|
|
$total_title = $variables['elements']['#title'];
|
|
|
|
$start_pos = strpos($total_title, '<span>') + strlen('<span>');
|
|
|
|
$end_pos = strpos($total_title, '</span>');
|
|
|
|
$processed_title = substr($total_title, $start_pos, $end_pos - $start_pos);
|
|
|
|
|
|
|
|
if ($processed_title !== 'Partenaires' || $processed_title !== 'Gouvernance') {
|
|
|
|
$suggestions[] = 'node__content_global';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-03-29 21:29:59 +01:00
|
|
|
}
|
2023-12-13 15:08:55 +01:00
|
|
|
|
2024-03-29 21:29:59 +01:00
|
|
|
function erabletheme_theme_suggestions_region_alter(array &$suggestions, array $variables) {
|
2024-04-26 18:08:25 +02:00
|
|
|
if (isset($variables['elements']['erabletheme_contenudelapageprincipale'])) {
|
|
|
|
// il ne faut pas baser le template sur des contenus !
|
|
|
|
// if ($variables['elements']['erabletheme_contenudelapageprincipale']['content']['#title'] == "Meet-up en ligne") {
|
|
|
|
// $suggestions[] = 'region__offre_meetup';
|
|
|
|
// } else
|
|
|
|
// if ($variables['elements']['erabletheme_contenudelapageprincipale']['content']['#title'] == "Foire aux Questions") {
|
|
|
|
// $suggestions[] = 'region__faq';
|
|
|
|
// }
|
|
|
|
|
|
|
|
// ça c'est mieux, se baser uniquement sur des infos structurelles (qui ne sont pas dynamiques)
|
|
|
|
$routematch = \Drupal::routeMatch();
|
|
|
|
$routename = $routematch->getRouteName();
|
|
|
|
switch ($routename) {
|
|
|
|
case 'faq.faq-page':
|
|
|
|
$suggestions[] = 'region__faq';
|
|
|
|
break;
|
|
|
|
case 'entity.node.canonical':
|
|
|
|
/** @var \Drupal\node\Entity\Node $node */
|
|
|
|
$node = $routematch->getParameter('node');
|
|
|
|
if ($node->getType() === 'offre') {
|
|
|
|
$suggestions[] = 'region__offre_meetup';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-03-29 21:29:59 +01:00
|
|
|
}
|
2023-12-06 05:01:23 +01:00
|
|
|
}
|