Hey guys,

Is it possible to disable the parent nice menu link? For example, when you hover over the menu, I only want the menus that drop down to be linked somewhere....I don't want people to click on the top menu item....

I understand you can set it to , but i don't even want that. I want it to link to nowhere.

Thanks

Comments

hello12345’s picture

i meant to say i understand you can set it to <front> but i don't want to do that

BradleyT’s picture

There's a javascript solution that basically makes the link so it doesn't go anywhere.

Put this in your template.php file (replacing pushbutton with your theme name)

function pushbutton_menu_item_link($item, $link_item) {  
  if ($item['path'] == '<none>') {
    $attributes['title'] = $link['description'];
    return '<a href="javascript:void(0)">'. $item['title'] .'</a>';
  }
  else {
    return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
  }
}

For the URL path use < none> (without the space)

You could play around with the return value to get it to do other things too, but this works pretty well for flyout menus. Someone else deserves credit for this, it's on one of the nice menus pages somewhere.

hello12345’s picture

Thanks!

valel46’s picture

BradleyT,

I just tried this with Drupal 6 and I received the following error when I tried to enter < none> as path.

The path '< none>' is either invalid or you do not have access to it.

waynedrupal’s picture

subscribed

ryanaghdam’s picture

Does the fix provided still work in Drupal 6?

beddoe’s picture

Looking to disable links for top menu items as well. Updates on this?

duckzland’s picture

I use this module to create a dummy menu item http://drupal.org/project/special_menu_items try them, its cleaner than using custom code in template.php

--------------------------------------------------------------------------------------------------------
if you can use drupal why use others?
VicTheme.com

Anonymous’s picture

Only problem is that module is for Drupal 6 only.

duckzland’s picture

or you can do it jQuery way :

$('your_id_or_class').click(function(e) {
 e.preventDefault() // or return false;
});

--------------------------------------------------------------------------------------------------------
if you can use drupal why use others?
VicTheme.com

arunnath’s picture

I guess it might be possible to do this with CSS. Specifically each menu item that needs to be disabled has an id or class. CSS rules can be used to disable the hyperlinks to the particular menu using the rules:

{
pointer-events: none;
cursor: default;
}

dago.aceves’s picture

http://drupal.org/project/special_menu_items
Allows you to set the path to and other nifty features for setting menu items when are not really menu links.

mrjambi’s picture

Yup, special_menu_items works great. The project page indicates that D8 may address the menu link issue natively but for now this seems to be a good solution. (Though you still will likely need to play with CSS to pretty up the menu items).