drupal-erable/web/themes/erabletheme/erabletheme.theme

75 lines
1.9 KiB
PHP

<?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) {
$t = "t";
}
/**
* Implements hook_preprocess_HOOK() for node.html.twig.
*/
function erabletheme_preprocess_form(&$variables) {
$t="t";
}
function erabletheme_preprocess_region(&$variables) {
$t="t";
}
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) {
if ($variables['title'] !== "") {
$view = $variables['title']['#markup'];
if (isset($view) && $view === 'Actualités') {
$suggestions[] = 'views_view__page_actus';
} elseif (isset($view) && $view === 'Gouvernance') {
$suggestions[] = 'views_view__content_gouvernance';
} elseif (isset($view) && $view === 'Partenaires') {
$suggestions[] = 'views_view__content_partenaires';
}
}
}
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';
}
}
}