clean les tests de custom modules qui fonctionnaient pas
This commit is contained in:
parent
a7fc5f4cb2
commit
a14717247f
|
@ -7,7 +7,6 @@ module:
|
|||
admin_toolbar: 0
|
||||
admin_toolbar_links_access_filter: 0
|
||||
advanced_text_formatter: 0
|
||||
alter_routing: 0
|
||||
audiofield: 0
|
||||
autocomplete_deluxe: 0
|
||||
ban: 0
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
name: 'Alter Routing'
|
||||
type: module
|
||||
description: 'Custom module to alter routing and redirect node/2 to the homepage.'
|
||||
core_version_requirement: ^8 || ^9 || ^10
|
||||
package: Custom
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_page().
|
||||
*/
|
||||
function alter_routing_preprocess_page(&$variables) {
|
||||
// Check if the current page is a node page.
|
||||
if (isset($page['#node']) && $page['#node'] instanceof \Drupal\node\NodeInterface) {
|
||||
// Load the front page content directly from its path.
|
||||
$front_page_path = \Drupal::config('system.site')->get('url');
|
||||
$front_page_node = \Drupal\node\Entity\Node::load(\Drupal::entityTypeManager()->getStorage('node')->getQuery()
|
||||
->condition('type', 'page') // Change this to the content type if needed
|
||||
->condition('status', 1)
|
||||
->sort('created', 'DESC')
|
||||
->execute()
|
||||
);
|
||||
|
||||
// If front page content is found, replace node content with front page content.
|
||||
if ($front_page_node) {
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
$rendered_content = $view_builder->view($front_page_node, 'full');
|
||||
$page['content']['#markup'] = \Drupal::service('renderer')->render($rendered_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue