Reputation: 801
I am trying to append a twig template on every page.
In Drupal 7, we basically append it using 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.
}
but in Drupal 8 there is no hook_page_alter
I think.
How to do this in drupal 8??
Upvotes: 1
Views: 7835
Reputation: 146
You can use hook_preprocess_page(&$variables)
in Drupal 8 to alter page content.
Example:
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']);
}
Upvotes: 7
Reputation: 21
What happened to hook_page_alter is explained here in the Drupal change record so in your case you'd probably use hook_page_bottom.
Upvotes: 2
Reputation: 147
even you can use kint() in the theme just attach your theme in variable
Upvotes: -1