Drupal 8中的HOOK_page_alter

时间:2016-12-14 14:51:57

标签: drupal drupal-8

我试图在每个页面上附加一个树枝模板 在Drupal 7中,我们基本上使用hook_page_alter

附加它
function hook_page_alter(&$page) { 
  $page['page_bottom']['devel']= array(
    '#type' => 'markup',
    '#markup' => '<div style="clear:both;">' . theme('TEST') . '</div>',
  ); // add test template on every page at bottom position.
}

但在Drupal 8中我认为没有hook_page_alter

如何在drupal 8中做到这一点??

2 个答案:

答案 0 :(得分:4)

您可以使用Drupal 8中的hook_preprocess_page(&$variables)来更改页面内容。

示例:

function bartik_preprocess_page(&$variables){

   $variables['page']['footer_fourt']['test']= array( 
        '#type' => 'markup', 
        '#markup' => '<div style="clear:both;">hello test</div>', );
   kint($variables['page']['footer_fourt']['test']);        
}

答案 1 :(得分:0)

即使你可以在主题中使用kint(),只需将你的主题附加在变量