I, like several others, am trying to create a navbar where the first submenu is open by default, unless another item is active. I can achieve this with hook_superfish_active_trail_alter() but I have no context about which superfish menu I'm altering. I only want to alter it for my main superfish menu, not my secondary menu.

I propose changing drupal_alter('superfish_active_trail', $trail); to drupal_alter('superfish_active_trail', $trail, $page_menu);. Patch attached. That way I can solve my problem in my theme with the following code.

<?php
/**
 * Implements hook superfish_active_trail_alter().
 */
function THEME_superfish_active_trail_alter(&$trail, $page_menu = NULL) {
  if (count($trail) == 0 && !empty($page_menu) && is_array($page_menu)) {
    if (($first = reset($page_menu)) && $first['link']['menu_name'] == 'main-menu') {
      $trail[] = $first['link']['mlid'];
    }
  }
}
?>

If you wanted to take this one step further you could provide this feature as a superfish setting.

Comments

mehrpadin’s picture

Issue summary: View changes
Status: Needs review » Fixed

Hey,

Patch applied, please check, thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.