Skip to content

Instantly share code, notes, and snippets.

@jacine
Last active July 6, 2016 18:46
Show Gist options
  • Save jacine/960a8460c48a8b592a78949a3d965d54 to your computer and use it in GitHub Desktop.
Save jacine/960a8460c48a8b592a78949a3d965d54 to your computer and use it in GitHub Desktop.
HTML in menu items D8
<?php
/**
* Implements hook_preprocess_menu().
*/
function THEME_preprocess_menu(&$vars, $hook) {
if ($hook == 'menu__main') {
$items = $vars['items'];
foreach ($items as $key => $item) {
$original_title = $vars['items'][$key]['title'];
$vars['items'][$key]['title'] = array(
'#markup' => $original_title,
'#allowed_tags' => array('span', 'b', 'i'),
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment