Hi everybody,

I just implement a feature that I want to share. For one of the project I work on, I had to do the same as the "Go to the page on double click" option but with just a click. This feature provide an AJAX reload of the page.
So here is the patch !

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ngo’s picture

not working, any idea?

mikeaja’s picture

Thanks for sharing. However, this is not ajax, there is no ajax reload of page.

Still, you pointed me in right direction, so that is good. This can be done much simpler if the admin option is not necessary (for me is not necessary when manually altering the code anyway). It just needs 1 extra line in dhtml_menu.js.

After these two lines:

 $(li).find('a:first').click(function(e) {
      Drupal.dhtmlMenu.toggleMenu($(li)); 

add following line:

 window.location = this.href; 

Just to clarify, this opens the page using a normal page refresh (not ajax) after the menu has expanded. I thought this effect would not be good, but actually I think it is ok.

It also solves another problem, which is that now the link that is shown when hovering over the menu item is used (before the main menu item would only expand / collapse menu, but still a link was shown in status bar which may confuse a user).

cburschka’s picture

I'm a bit confused here - if you add this, then the dynamic menu expansion doesn't have any effect as the page will always change statically. This appears to be equivalent to simply disabling the module.

mikeaja’s picture

That's not the way I see it at all. I've been using this now on a production site for a couple of weeks.

I imagine that how well this works (and looks) may depend on the server hosting the site. I've got this Drupal site on a very well setup VDS, so site is quick. I mention this because it may or may not be key here.

The effect is different (in my opinion) to disabling the module. What I get now is the module expanding in the DHTML slide way, and as it has expanded, the page refreshes. On my site you hardly notice the page refresh.

BouM’s picture

cburschka : At the beginning, I said the same thing as you : why don't you just disabled the DHTML menu ?

The aim is to keep the DHTML slide effect.
As it wasn't a really an issue in the website, I did it like this because it was the simplest the way to do it (in my point of view)

I did a checkbox to make it enable or disable easier

mikeaja’s picture

Thanks again BouM for point me in the right direction with the change.

I think it is important to see this menu from a users point of view. The default menu shows a link to a page when you hover over the intial menu item.

So, if my menu is like this:

Page A
Page aa
Page ab
Page ac

Page B
Page ba
Page bb

Then if you hover over Page A or Page B option, you will see the link to a page. However, this link does nothing. Clicking the option opens / closes the menu. This could be confusing to a user who is used to normal links. The change suggested by BouM also solves this problem.

amperisk’s picture

FileSize
1001 bytes

The patch needs to be fixed. On line 9 of the patch there should be a apostrophe before click.
It currently looks like this: + click' => t('Go to the page on click.'),
It should look like this: + 'click' => t('Go to the page on click.'),

or you can add an apostrophe before click to line 23 of dhtml_menu.admin.inc ( in the module directory, if you applied the old patch).
It currently looks like this: click' => t('Go to the page on click.'),
It should look like this: 'click' => t('Go to the page on click.'),

After that correction everything works perfectly.
I attached a corrected version of the patch.

nonius’s picture

After these two lines:

 $(li).find('a:first').click(function(e) {
      Drupal.dhtmlMenu.toggleMenu($(li)); 
add following line:

 window.location = this.href; 

works like a charm.

But maybe worth mentioning that the cache needs to be cleared in order to see it work (when js caching is enabled)

gr.

sven

DamienMcKenna’s picture

Why not combine the 'click' and 'double-click' options into one selector?

DamienMcKenna’s picture

FileSize
1.58 KB

Here's an updated version of the patch from #7 with some coding standard fixes.

I didn't combine the single-click and double-click options into a single selector as it would involve having to either a) remove the 'click' options from the 'dhtml_menu_effects' variable as the admin page's form uses a single '#options' field to display all of the checkboxes (thus can't have radio buttons or a selector), b) us some JS to make them behave as a toggle.

DamienMcKenna’s picture

Status: Active » Needs review
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.

Thanks to everyone for your time and contribution!

vuil’s picture