getParameter('node'); if ($node){ $variables['attributes']['class'][] = 'node-type-' . $node->bundle(); $variables['attributes']['class'][] = 'node-id-' . $node->id(); } } /** * Implements hook_preprocess_HOOK() for page.html.twig. */ function reha_preprocess_page(&$variables) { } /** * Implements hook_preprocess_HOOK() for node.html.twig. */ function reha_preprocess_node(&$variables) { $node = &$variables['node']; $variables['attributes']['class'][] = 'node-type-' . $node->gettype(); if ($variables['node']->getType() == 'site') { $fields_to_exclude = [ 'field--name-field-image', ]; $filtered_content = []; $image_field_content = ''; foreach ($variables['content'] as $field_name => $field_content) { if (!in_array($field_name, $fields_to_exclude)) { $filtered_content[$field_name] = $field_content; } else { $image_field_content = $field_content; } } $variables['filtered_content'] = $filtered_content; $variables['image_field_content'] = $image_field_content; } } function reha_preprocess_block(&$variables) { 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); $variables['content']['reha'] = array( '#theme' => 'item_list', '#items' => [ 'operations' => [ "add_operation" => $link->toRenderable(), "description" => [ "#markup" => Markup::create("

Créer un compte pour charger une opération

") ] ] ] ); } if ($variables['plugin_id'] === "page_title_block") { if (\Drupal::routeMatch()->getRouteName() === 'node.add') { $node_type = \Drupal::routeMatch()->getParameter('node_type'); if ($node_type->id() === 'operation') { $variables['content'] = [ '#type' => 'page_title', '#title' => 'Proposer une opération' ]; } } } }