If you're like me and you needed the 'active' class on the active LI element and not just the A, then put this code

	if (isset($menu_item['link']['href']) && ($menu_item['link']['href'] == $_GET['q'] || ($menu_item['link']['href'] == '<front>' && drupal_is_front_page()))
           && (empty($menu_item['link']['language']) || $menu_item['link']['language']->language == $language_url->language)) {
        $item_class[] = 'active';
      }

just underneath this line

$mlid = $menu_item['link']['mlid'];

in your superfish.module file, which for me was on line 944. Currently, the Superfish module doesn't seem to support language neutral links, because there is no $menu_item['link']['language'] in the $menu_item array it builds. I left it in however in case support comes out in the future.

This is a feature request.. It'd be great to be able to apply markup to active elements in the menu config, much as you can wrap html / css around elements now.

Comments

mehrpadin’s picture

Hey Shawn,

Is there anything wrong with the active-trail class? :)

mehrpadin’s picture

Status: Active » Closed (works as designed)
danielgeez’s picture

There's nothing wrong with the active-trail class. We just want to be able to apply it to the LI item as well as the A. I'm using the latest version and this module still doesn't seem to allow this.

danielgeez’s picture

Issue summary: View changes
Status: Closed (works as designed) » Active
mehrpadin’s picture

Hey there,

Can you tell me why exactly would you need that? I mean, you can easily select active <li> elements already:

li.active-trail { background: #000; }

Or if it's the link inside it:

li.active-trail > a { font-weight: bold; }

?

dww’s picture

Title: Active Class on LI Element » Active class on <li> element
Version: 7.x-1.9-beta4 » 7.x-1.x-dev
Category: Feature request » Bug report

The reason you want the "active" class on the <li> itself, not just relying on active-trail and having "active" on the <a>, is for the superfish.js feature "sf-smallscreen-select". See libraries/superfish/sfsmallscreen.js and search for "addSelected" to see what I'm talking about. That feature doesn't work at all unless you override theme_superfish_menu_item() to set the 'active' class manually (like core itself does).

Since the lack of this class is breaking a feature provided by this module, calling this a bug.

mehrpadin’s picture

Hey there,

Allow me to disagree :)

A) Core does not do that, it however does give <a> elements an active-trail class in addition to their parent <li> lately - for whatever reason that is unknown to me and actually hardly makes any sense either etc etc.

B) If you're referring to the line #88 (master branch) of the sfsmallscreen.js, I'm afraid it's looking for the class not on <li> elements but on <a> & possible <span> elements, look at the line #78 where parent is defined.

Thanks for your comment anyway, and please revert to feature request, thank you.

dww’s picture

Category: Bug report » Feature request

Re: A) I dunno. ;)

Re: B) I figured it out a while ago, and forgot to post back here. You also need to enable the "Copy the hyperlink classes to the <option> elements of the <select>" checkbox for the "sf-smallscreen-select" feature to work. It'd be nice if that was documented or even toggled via #states or something so that if you turn on sf-smallscreen-select it automatically checks this other setting for you. Perhaps that should be moved into a separate feature request.

Cheers,
-Derek

LOBsTerr’s picture

Status: Active » Closed (outdated)