|
@@ -4,6 +4,7 @@
|
|
|
use Drupal\Core\Url;
|
|
|
use Drupal\Core\Link;
|
|
|
use Drupal\Core\Render\Markup;
|
|
|
+use Drupal\Component\Utility\Html;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -63,6 +64,28 @@ function reha_preprocess_html(&$variables) {
|
|
|
$variables['files_field_content'] = $files_field_content;
|
|
|
$variables['liens_field_content'] = $liens_field_content;
|
|
|
}
|
|
|
+
|
|
|
+ // if ($node->getType() == 'site') {
|
|
|
+ // $blocks_to_exclude = [
|
|
|
+ // 'block-entity-fieldnodefield-image',
|
|
|
+ // ];
|
|
|
+
|
|
|
+ // $filtered_block_content = [];
|
|
|
+ // $image_block_content = '';
|
|
|
+
|
|
|
+ // foreach ($variables['content'] as $block_name => $field_content) {
|
|
|
+ // if (!in_array($block_name, $blocks_to_exclude)) {
|
|
|
+ // $filtered_block_content[$block_name] = $field_content;
|
|
|
+ // } else {
|
|
|
+ // $image_block_content = $field_content;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // Set variables for the template
|
|
|
+ // $variables['filtered_block_content'] = $filtered_block_content;
|
|
|
+ // $variables['image_block_content'] = $image_block_content;
|
|
|
+
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -137,6 +160,13 @@ function reha_preprocess_page(&$variables) {
|
|
|
//https://www.hashbangcode.com/article/drupal-9-programmatically-creating-and-using-urls-and-links
|
|
|
|
|
|
function reha_preprocess_block(&$variables) {
|
|
|
+
|
|
|
+// // Conserver les IDs existants et générer un ID unique uniquement si aucun ID n'est présent
|
|
|
+// if (empty($variables['attributes']['id'])) {
|
|
|
+// $block_id = 'block-' . uniqid();
|
|
|
+// $variables['attributes']['id'] = $block_id;
|
|
|
+// }
|
|
|
+
|
|
|
if ($variables['plugin_id'] === "user_login_block") {
|
|
|
$url = new Url('user.register', [], ['query' => ['destination' => '/node/add/operation']]);
|
|
|
$link = new Link('proposer une opération', $url);
|
|
@@ -162,6 +192,22 @@ function reha_preprocess_block(&$variables) {
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // // Extraction du texte du <h2> et transformation en ID
|
|
|
+ // if (isset($variables['content']['#contextual_links']['block']['h2'])) {
|
|
|
+ // $h2_text = $variables['content']['#contextual_links']['block']['h2'];
|
|
|
+ // $block_id = Html::cleanCssIdentifier($h2_text);
|
|
|
+ // $variables['attributes']['id'] = $block_id;
|
|
|
+ // } elseif (isset($variables['content']['#block_content']['body']['0']['#text'])) {
|
|
|
+ // $h2_text = $variables['content']['#block_content']['body']['0']['#text'];
|
|
|
+ // $block_id = Html::cleanCssIdentifier(strip_tags($h2_text));
|
|
|
+ // $variables['attributes']['id'] = $block_id;
|
|
|
+ // } else {
|
|
|
+ // // Fallback ID if no <h2> is found
|
|
|
+ // $block_id = Html::cleanCssIdentifier($variables['plugin_id']);
|
|
|
+ // $variables['attributes']['id'] = $block_id;
|
|
|
+ // }
|
|
|
+
|
|
|
}
|
|
|
// if ($variables['plugin_id'] == 'actus-block-1') {
|
|
|
// $fields_to_exclude = [
|