3

I have created a menu with items and one item has second level. So I created child links.

The problem is that the item which has second level links to some page and I would like to make it to link nowhere. It would be only collaps/expand link that shows or hides the child links.

I have found only possibility to set the link as <front> but this does not make what I want. Is this possible in Drupal 7?

OK, I found some modules the could help, Menu block and Nice menus but it seems that my problem could have some easier solution. How would you solve it? With some javascript?

thank you

  • Does it need to be in the same menu? You could just create two menus and give it then style them to seem like they're the same menu – chrisjlee May 11 '11 at 20:01
  • @Chris J. Lee I'd rather have it one menu. – xralf May 12 '11 at 6:13
0
+50

There are actually 2 links that can help you with your problem:

Menu items that are not links (Notice that the discussion starts from drupal 5, so you will have to skip to the drupal-7-specific comments: hit ctrl+f and search for Drupal 7)

Javascript to Disable Drupal Parent Menu Links (This solution is based on jQuery and CSS, so you won't have to modify the template.php file or install any extra modules)

3

There are two modules I know of specifically for allowing menu items that are not 'proper' links. There's Special menu items (which doesn't have a D7 release, but there's a patch) and Menu Firstchild (they're not identical in features, but both do what you want I believe).

You might also be interested in DHTML Menu which has a beta1 release for D7.

2

One thing you could do is to make the first level link manually, and make it identical to the 'primary' or most important second level link.

So you'd have something like this:

  • About (about/who-we-are/)
    • Who We Are (about/who-we-are/)
    • Contact Us (about/contact-us/)
    • etc.

Then, using Nice Menus (or something else), you can make the second level menu appear as someone hovers over the primary menu items. Some users might click on this primary link, but this sends them to your desired second-level page.

2

You can use menu attributes to create an id for the menu item. With jquery you can then target that menu item and add an onclick event to show and hide your children to override the default on click.

if($('#your-id').get(0)) {
  $('#your-id').click(function(){
    $('ul', this).toggle();
    return false;
  });
}
0

https://drupal.org/project/special_menu_items does exactly what you want...

Special menu items is a Drupal module that provides placeholder and separator menu items.

A placeholder is a menu item which is not a link. It is useful with dynamic drop down menus where we want to have a parent menu item which is not linking to a page but just acting as a parent grouping some menu items below it.

A separator menu item is something like "-------" which is not linking anywhere but merely a mean to structure menus and "separate" menu items visually.

Menu item container provides similar functionality.

  • Can you please add more information regarding above module ? Only link answers are discouraged in Stack Exchange.. – Anil Sagar May 3 '14 at 7:08
  • Based on the text on the project page, it doesn't look to me like Special menu items is relevant for the OPs question. Can you add some words of your own that explains why you think thie module will help the OP create a collapsible menu element to hide child links. – Free Radical May 3 '14 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.