drupal-caravane/web/themes/custom/caravane/caravane.theme

69 lines
2.3 KiB
PHP

<?php
use GuzzleHttp\Psr7\Uri;
/**
* @file
* Functions to support theming in the caravane theme.
*/
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';
}else{
$page['#attached']['library'][] = 'caravane/global';
}
}
/**
* 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) {
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();
}
}
/**
* Implements hook_preprocess_HOOK() for node.html.twig.
*/
function caravane_preprocess_node(&$variables) {
}
function cavarane_preprocess_block(&$variables) {
}
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';
}
}