2024-07-10 16:16:51 +02:00
|
|
|
<?php
|
2024-09-11 19:53:18 +02:00
|
|
|
use GuzzleHttp\Psr7\Uri;
|
2024-07-10 16:16:51 +02:00
|
|
|
/**
|
|
|
|
* @file
|
2024-07-15 16:34:28 +02:00
|
|
|
* Functions to support theming in the caravane theme.
|
2024-07-10 16:16:51 +02:00
|
|
|
*/
|
|
|
|
|
2024-07-15 16:34:28 +02:00
|
|
|
function caravane_page_attachments_alter(&$page) {
|
|
|
|
if (getenv('APP_ENV') === 'development') {
|
|
|
|
// $attachments['#attached']['html_head'][] = [['src' => 'http://localhost:5173/@vite/client', 'type' => 'module'],'vite-client'];
|
|
|
|
// $page['#attached']['library'][] = 'http://localhost:5173/@vite/client';
|
|
|
|
// $attachments['#attached']['html_head'][] = [['src' => 'http://localhost:5173/assets/js/main.js', 'type' => 'module'],'vite-main'];
|
|
|
|
// $page['#attached']['library'][] = 'http://localhost:5173/assets/js/main.js';
|
|
|
|
$page['#attached']['library'][] = 'caravane/vitehmr';
|
2024-07-16 17:01:09 +02:00
|
|
|
}else{
|
|
|
|
$page['#attached']['library'][] = 'caravane/global';
|
2024-07-15 16:34:28 +02:00
|
|
|
}
|
|
|
|
}
|
2024-07-10 16:16:51 +02:00
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_HOOK() for html.html.twig.
|
|
|
|
*/
|
|
|
|
function caravane_preprocess_html(&$variables) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_HOOK() for page.html.twig.
|
|
|
|
*/
|
|
|
|
function caravane_preprocess_page(&$variables) {
|
|
|
|
|
2024-09-11 19:53:18 +02:00
|
|
|
if (\Drupal::service('path.current')->getPath() == '/node/2') {
|
|
|
|
// Fetch content from the homepage.
|
|
|
|
// $homepage_url = \Drupal::service('path.current')->getPath();
|
|
|
|
$base_url = \Drupal::request()->getSchemeAndHttpHost();
|
|
|
|
$uri = new Uri($base_url);
|
|
|
|
$homepage_content = \Drupal::httpClient()->get($uri);
|
|
|
|
$variables['homepage_content'] = $homepage_content->getBody();
|
|
|
|
}
|
2024-07-10 16:16:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_HOOK() for node.html.twig.
|
|
|
|
*/
|
|
|
|
function caravane_preprocess_node(&$variables) {
|
|
|
|
|
|
|
|
}
|
2024-07-16 17:01:09 +02:00
|
|
|
|
2024-08-09 17:04:53 +02:00
|
|
|
function cavarane_preprocess_block(&$variables) {
|
2024-08-05 21:08:09 +02:00
|
|
|
|
2024-08-09 17:04:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function caravane_theme_suggestions_views_view_field_alter(array &$suggestions, array $variables) {
|
|
|
|
$view = $variables['view'];
|
|
|
|
$display_id = $variables['view']->current_display;
|
|
|
|
if ($display_id == 'block_1' && $view->id() == 'etapes') {
|
|
|
|
$suggestions[] = 'views_view_field__block_1__etape_list';
|
|
|
|
}
|
|
|
|
if ($display_id == 'block_2') {
|
|
|
|
$suggestions[] = 'views_view_field__block_2__popup_map';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function caravane_theme_suggestions_views_view_fields_alter(array &$suggestions, array $variables) {
|
|
|
|
$view = $variables['view'];
|
|
|
|
$display_id = $variables['view']->current_display;
|
|
|
|
$view_id = $view->id();
|
|
|
|
if ($display_id == 'block_1' && $view_id == 'etapes') {
|
|
|
|
$suggestions[] = 'views_view_fields__block_2__liste_etapes';
|
|
|
|
}
|
2024-08-05 21:08:09 +02:00
|
|
|
}
|