function menu_fields_preprocess_entity in Menu Item Fields 7
Implements hook_preprocess_entity().
File
- ./
menu_fields.module, line 183 - Main file contain hooks/functions.
Code
function menu_fields_preprocess_entity(&$vars) {
if ($vars['entity_type'] == 'menu_fields') {
// Pass the menu link to the template.
if (!empty($vars['menu_fields']->link)) {
// If this is from rendering the menu link, the entity will have the
// 'link' property already set via menu_fields_preprocess_menu_link().
$vars['link'] = $vars['menu_fields']->link;
}
else {
// This comes directly from entity_view, no menu link has been rendered
// yet, which means that menu_fields_preprocess_menu_link() has not been
// triggered neither.
$vars['link'] = menu_link_load($vars['menu_fields']->mlid);
}
// Suggest our own template which doesn't print the title/url to the entity.
$vars['theme_hook_suggestions'][] = 'entity__menu_fields';
$vars['theme_hook_suggestions'][] = 'entity__menu_fields';
$vars['theme_hook_suggestions'][] = 'entity__menu_fields__' . $vars['elements']['#bundle'];
$vars['theme_hook_suggestions'][] = 'entity__menu_fields__' . $vars['elements']['#bundle'] . '__' . $vars['elements']['#view_mode'];
}
}