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”

About these ads

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

  1. Pingback: Working with menus in Drupal 7 @ 2 | Eureka!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s