Hook not working in drupal 8

1.2k views Asked by At
<?php
/**
 * @file
 */
/**
 * Implements hook_page_alter().
 */
function glue_page_alter(&$page) {
    $page['content']['bartik.content']['content']['#markup'] = 'Hello Content!';
}

What wrong with this hook? It wont run (8.4.3). I've cleared the cache too

1

There are 1 answers

5
AudioBubble On

In Drupal 7, hook_page_alter was a convenient way to go when we needed to modify page elements that were added by other modules. Drupal 8 does away with this hook - hopefully for the better. To fill the void created by hook_page_alter’s dismissal, the following hooks have been introduced.

hook_page_attachments()
hook_page_attachments_alter()
hook_page_top()
hook_page_bottom()
hook_theme_suggestions_HOOK()
hook_theme_suggestions_HOOK_alter()

Source: https://cryptic.zone/blog/where-hook_page_alter-drupal-8