简体   繁体   English

钩子在drupal 8中不起作用

[英]Hook not working in drupal 8

<?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). 它不会运行(8.4.3)。 I've cleared the cache too 我也清除了缓存

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 7中,当我们需要修改由其他模块添加的页面元素时,hook_page_alter是一种便捷的方法。 Drupal 8 does away with this hook - hopefully for the better. Drupal 8消除了这个问题-希望更好。 To fill the void created by hook_page_alter's dismissal, the following hooks have been introduced. 为了填补hook_page_alter被解雇所造成的空白,引入了以下钩子。

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 资料来源: https : //cryptic.zone/blog/where-hook_page_alter-drupal-8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM