function _micon_menu_preprocess_menu_items in Micon 2.x
Same name and namespace in other branches
- 8 micon_menu/micon_menu.module \_micon_menu_preprocess_menu_items()
Helper function to iterate over each menu item and utilize icon.
1 call to _micon_menu_preprocess_menu_items()
- micon_menu_preprocess_menu in micon_menu/
micon_menu.module - Implements hook_preprocess_menu().
File
- micon_menu/
micon_menu.module, line 190 - Contains micon_menu.module.
Code
function _micon_menu_preprocess_menu_items($items) {
foreach ($items as &$item) {
$options = $item['url']
->getOptions();
if (!empty($options['attributes']['data-icon'])) {
$icon = MiconIconize::iconize($item['title'])
->setIcon($options['attributes']['data-icon']);
if (!empty($options['attributes']['data-icon-position']) && $options['attributes']['data-icon-position'] === 'after') {
$icon
->setIconAfter();
}
$item['title'] = $icon
->render();
unset($options['attributes']['data-icon']);
$item['url']
->setOptions($options);
}
if (!empty($item['below'])) {
$item['below'] = _micon_menu_preprocess_menu_items($item['below']);
}
}
return $items;
}