It seems there is an active state patch that works for Drupal 5.x but not 6.x. One member suggested requesting this feature for 6.x. I'm fairly new to Drupal and this seems to be the best module for using images for menu items.

Any help or suggestions are greatly appreciated!

Comments

headkit’s picture

you are the man, starting the right issue.
i am very interested!
thanx!

headkit’s picture

Priority: Normal » Critical

nothing new here?
i need this really quick.
i would also pay some money if someone clears this request.

gaia’s picture

oh, i need this feature as well.

awolfey’s picture

StatusFileSize
new1000 bytes
new1000 bytes

Here is a patch that adds the classes current and active-trail to the active menu item. I have it working but have not thoroughly tested it.

This does not set the active image to the rollover image, but it does let you do other things. I used it with the lavalamp jquery menu to set the active item.

awolfey’s picture

StatusFileSize
new1.49 KB

Here's a patch against imagemenu.module 22 Apr 2008 15:06:16 -0000 1.7.2.2

This sets the active menu item image to the rollover image, and the rollover to the original image.

It also includes the added classes from the above patch.

Working for me, but needs testing without clean urls and various other front page settings, aliases, etc.

awolfey’s picture

Version: 6.x-1.0-rc5 » 6.x-1.0
Status: Patch (to be ported) » Needs review
StatusFileSize
new1.62 KB

Oops. Use this one instead. Patch in #5 does not switch rollover to the original image.

tunic’s picture

I have the same problem, and this patch seems to fix it. I'm using clean urls with pathauto, multilingual site with language prefix (URLs like http://mysite/en/exampleContent and http://mysite/es/contenidoDeEjemplo) and awolfey patch works fine, at least for the moment.

Thank you very much, awolfey.

kla2t’s picture

Certainly the patch is an improvement of the imagemenu module, but actually it seems to work only partially for me. The classes "current active-trail" are added to nothing but the lowest active menu level. Example: If I have a page with the URL "projects/type/residential", only the "residential" entry at the last of the three menu levels is highlighted by the active-trail property, but neither "projects" nor "type". This is not what I would call a trail...
Is it possible to set the active-trail class to all parent levels, too? Maybe it does not work properly because my paths don't correspond to nodes - they are generated by different views (one for "projects", one for "projects/type" and so on).
Any help will be highly appreciated!

awolfey’s picture

kla2t: Unfortunately I don't have time to figure this out with views. You might look at http://drupal.org/project/menutrails and see how they do it. Also see http://drupal.org/node/340725. I got this working with normal menus, but I did not need it for imagemenu.

kla2t’s picture

Thank you, Aaron. I tried Menutrails, too, but I couldn't get it integrated with Views plus Imagemenu. It seems that I will drop the whole Imagemenu thing in favor of Nice Menus. The latest dev version assigns not only unique IDs to each menu entry, but also active-trail classes to all parents of the current entry. Thus, you can create graphical menus by CSS along the lines of http://drupal.org/node/209989 - with individual background images for menu entries and invisible (but readable) text. This is not a very flexible, but apparently a working solution.

kla2t’s picture

Status: Needs review » Closed (fixed)
Anonymous’s picture

Status: Closed (fixed) » Needs work

patch #6 does not work with url aliases

menu path | page alias
--
node/2 | node/2: OK
node/2 | content/biography: NOT OK - patch #6 does not check that this alias is in fact "node/2" and consequently fails to keep the menu active

awolfey’s picture

I have not looked at this since first posted in March. The project I used it for ended up with another menu option. I can try to look, but if someone else is using this now, please don't wait for me to get to it.

kunago’s picture

StatusFileSize
new1.58 KB

I tried to fix the patch provided in #6. This one is working for me in all situations.

lee20’s picture

Status: Needs work » Reviewed & tested by the community

I just tested the patch in #14 against version 1.1.

Works great!

Although the use of "active-trail" doesn't work as it should. The active-trail class should be applied to the ancestors of the active item. But the active trail is only assigned to the active item and not to the ancestors, which is not a true indication of the active trail. But this should probably be requested in another issue as it is beyond the "active state' request?

richard moger’s picture

Thanks worked a charm. One small issue, doesn't work for a homepage imagemenu item, sure I'll get round that though.

richard moger’s picture

Update. Added line below to my codebase for my use case of homepage having it's own imagemenu item. Patch isn't setting the image path to the rollover one so homepage image wasn't being set correctly when homepage active.

//check for <front>
 if ($active_path == variable_get('site_frontpage', '') && $item['path'] == '<front>') {
   $active_path = $item['path']; 
	$class .= ' current active-trail';
	$item['imagepath'] = $item['mouseover'];           // set path 
 }

p.s. about as small as you can get but my first drupal contrib!

kunago’s picture

Version: 6.x-1.0 » 6.x-1.1
Assigned: insitemotion » kunago
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.55 KB

I updated my own patch so posting another one. I minified the condition for $item_path from many lines to one single line and have also fixed the drichar's issue with front page. It works for my menus.

Give it a try.

gambiteer’s picture

works for me

marcus_clements’s picture

Priority: Critical » Normal
Status: Needs review » Needs work

Thanks for the patches.

I've added active-trail class to list items and active class to links when appropriate. I took out "current" because Garland doesn't put it in - is it necessary?
I've made a setting to choose whether or not to set the rollover image as the active state.
The active-trail class is still not applied to the relevant list items higher in the menu tree. If anyone wants to supply a patch to do that I will happily include it.

The changes will be in the nightly dev snapshot. Please test and review.

cheers

rayvaughn

kunago’s picture

I was working on the "active" state while ago but after couple of hours I had to give up. It was not working. For the inspiration I looked at the menu module and found out the way to set the active state for even child items would require a major redesign of the Imagemenu module.

Alex Andrascu’s picture

#20 it's working fine on my side

bluesherpa’s picture

Version: 6.x-1.1 » 6.x-1.2

How can the rollover image be used as the active menu option? I have the latest dev version of imagemenu installed. The notes say the feature is now possible. I'm just not sure how to take advantage of it.
Thanks =)

mvalverde’s picture

Version: 6.x-1.2 » 6.x-1.3
Category: feature » bug

... the Problem still seems to remains with version 6.x-1.3 and even with the latest dev version.

We're using "image menu" in combination with "menu trails".
When switching to the garland theme which is not using "image menu" the active trail and active css classes are properly set on the menu item.
When using our production theme with "image menu" those classes were not set in exctly the same situation.

THX!
Marco Valverde, explido Software

susanb’s picture

Version: 6.x-1.3 » 6.x-1.x-dev

I have two imagemenus on my site.

on menu #1 - I want to use the 'rollover image for active menu item'

on menu #2 - I do not want the rollover image to be used for the active state!

Anyone know how to do this easily?

Thanks in advance!

pobster’s picture

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

Closing as D6.x is now unsupported.