I have a module with a menu which I build like this:
in moduleName.module
function moduleName_menu() {
$items = array(
'title' => 'whatever',
'page callback' => 'something_callback',
...
'type' => MENU_NORMAL_ITEM
);
return items;
}
Now I want certain items to be disabled (Clicking them should do nothing, similar to using disabled="disabled"
on a <input type="button">
). I tried adding '#disabled' => true
, as I would do for form items, but that didn't work. How can I disable menu items?
UPDATE
I tried using myTheme_menu_link
to disable the menu items. So in the code above, I add 'disabled' => true
or 'disabled' => false
to certain menu items. Then, my theme_menu_link
function looks like this:
function vitrine_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
if (isset($element['disabled']) && $element['disabled']) {
error_log('Hoping to see this somewhere in the log');
$output = '<a>' . $element['#title'] . '</a>';
}
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
I test it by emptying all caches, which rebuilds the menu, but still, the error I'm trying to log never get's logged. It seems as though my 'disabled' => true
never makes it to this function...