Working with menus in Drupal 7 @ 3

We have Special menu items module and Nice Menus which makes Drupal menu editing much more convenient.
Working with menus in Drupal 7 @ 1 – Special menu items module
Working with menus in Drupal 7 @ 2 – Nice Menus

But there is a bug when using both of them together. After you setup a Nice menu and you set the parent menu item path to <nolink>, the hyperlink is still there.

 

I am not sure if this bug will be fixed in the near future, but in case you come across it, you can fix it by adding the following code in your theme template.php.

/**
 * Fix nice menu and special menu items module conflict
 * Reference: http://drupal.org/node/1273602#comment-5347922
 */
function <theme>_nice_menus_menu_item_link($variables) {
  if (empty($variables['element']['#localized_options'])) {
    $variables['element']['#localized_options'] = array();
  }
  if ($variables['element']['#href'] == '<nolink>') {
  return '<a class="nolink" href="#">' . $variables['element']['#title'] . '</a>';
  } else {
  return l($variables['element']['#title'], $variables['element']['#href'], $variables['element']['#localized_options']);
  }
}

 

Done =)

Previous: Working with menus in Drupal 7 @ 2

Reference: Conflict with other module make nolink creates “/” & “Page not found”

3 thoughts on “Working with menus in Drupal 7 @ 3”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.