Conflicts with http://drupal.org/project/special_menu_items
When there are items with a "nolink" path (simple containers) and they are not expanded by default,
DHTML Menu may display warnings:

warning: Invalid argument supplied for foreach() in /XXXX/sites/all/modules/dhtml_menu/dhtml_menu.module on line 175.

Also DHTML Menu continues acting on a menu even if disabled in settings.

CommentFileSizeAuthor
#3 dhtml_menu-508252.patch897 bytesraphaelhuefner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bwinett’s picture

Has anyone figured out how to fix this?

anrikun’s picture

You may try http://drupal.org/project/menu_firstchild
It supports DHTML Menu.

raphaelhuefner’s picture

Status: Active » Needs review
FileSize
897 bytes

I worked on this issue because I had to "scratch my employer's itch" ...

To get rid of the warning: Invalid argument supplied for foreach() in /home/raphael/projects/vtrunk/sites/all/modules/dhtml_menu/dhtml_menu.module on line 175., the "Expanded"-checkbox of all the "nolink"-items should get switched on. But that is not the whole story ... I needed to make a patch, also, which I'm going to describe next:

The JavaScript in dhtml_menu.js tries to attach toggleMenu() (the collapse/expand-behavior) on the appropriate <a>-tag, but with the "nolink"-item of http://drupal.org/project/special_menu_items it should better do this to a <span class="nolink">-tag. So I augmented the jQuery-Selector from being 'a:first' to 'a:first, span.nolink:first', but in "nolink"-items, this will still search for an <a>-tag, even among deeper descendants, which might be a leaf menu item, for instance, which should not toggle anything.

So I additionally changed the .find(selector)-call into a .children().filter(selector) chain, in order to assure only direct descendant <a>-tags get the toggleMenu()-behavior.

Furthermore I added a means of the two modules communicating about the actual HTML-code being used to mark "nolink"-items, simply by querying Drupal.settings.specialMenuItems.nolinkSelector on this end. As long as this variable is not set, there is a fallback, of course. I still have to file an issue with http://drupal.org/project/special_menu_items to get this variable set in the first place. I will crosslink the two issues as soon as I know the other issue number.

By the way, #585984: Menu item with 'no' path might be a duplicate of this issue here.

raphaelhuefner’s picture

The corresponding issue over at http://drupal.org/project/special_menu_items is #661166: Make inter-operable with dhtml_menu , which will set the JavaScript variable Drupal.settings.specialMenuItems.nolinkSelector.

srobert72’s picture

Same conflict with Admin module. DHTML Menu + Admin modules give me this error :

warning: Invalid argument supplied for foreach() in /home/drupal/sites/all/modules/dhtml_menu/dhtml_menu.module on line 175.

I use :
dhtml_menu 6.x-3.x-dev (2009-Dec-07)
admin 6.x-2.0-beta2 (2010-Feb-24)

adrianmak’s picture

#2: the menu_firstchild module link the parent link to it's first menu child that is not my desire. On the other hand, special menu items is what I want to , ie no link on the parent item.

anrikun’s picture

#6: But if you use menu_firstchild with dhtml_menu, you might get what you need as the link on the parent item will only expand/collapse children.

adrianmak’s picture

#7: I tried menu_firstchild with dhtml module, I added < firstchild > on parent menu item path , but it still link to first child path while clicking the parent menu item

anrikun’s picture

Yes the link is still here but dhtml_menu should override it with the expand/collapse effect.

adrianmak’s picture

Yes but the parent link still clickable even though the child items are expanded.

AdrianB’s picture

Subscribing.

manuel.adan’s picture

In the meantime, special menu items v. 6.x-1.4 runs ok with dhtml_menu 6.x-3.5

jasondecamp’s picture

Tried Patch from #3 (raphaelhuefner). Still get annoying error when links are not set to be expanded by default. Would be nice to fix this. Other than that, the patch appears to work as long as you apply the patches to both DHTML and Special_Menu_Items.

Thanks Raphael

geerlingguy’s picture

Subscribe.

beckyjohnson’s picture

This combo does not work for me. Special menu items 6.x-1.4 works with DHTML but it breaks Menu Block 6.x-2.3. Items that have special menu attributes won't expand.

beckyjohnson’s picture

What version of DHTML did you test this patch on? I got the special menu items patch on ok but even with this patch as well, DHTML menu is still broken for me.

cburschka’s picture

A few changes to 6.x-3.x-dev were committed since the 3.5 release, notably including some sanity checks in the menu traversal (and compatibility with devel_themer, but that was such a specific fix it shouldn't have affected anything else). For example, the error message mentioned in #5 should no longer occur.

It'd be good to know if the conflicts remain in the 6.x-3.x-dev version.

Nico7’s picture

Hi,

It's 2012 and the issue is still not resolved.
When the parent item is a nolink item, it is being shown as a link. If I click on the link, an error message occurs.
There shouldn't be a link at all.

Has anyone solved this?

El Bandito’s picture

or found a workaround ?

Cheers

Nico7’s picture

Hi El Bandito,

I solved the problem by going to the special menu items settings and replacing span with a href="#" (you have to put < and > around).

Now, special menu items works fine with DHTML module. I hope this works for you too.

Regards, Nico

El Bandito’s picture

Nico

I tried your suggestion, but my problem is that as soon as I enable this module my DHTML menus stop behaving properly - specifically clicking on a parent menu item causes several menus to expand, but not the one I actually clicked on. Very strange.

Hmmmmmn.

El B

vuil’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

I closed the issue as Closed (outdated) because it is for unsupported 6.x version of Drupal.

Thank you for the contribution!