How to expand menu items by default? We are having an issue where the "Show as expanded" checkbox is false whenever a new link is generated regardless of menu link weight. 

Using the Superfish module we are displaying the menu block and tried to the following below to see if we can have the menu links expanded by default. However, during testing this is failing. We are using the latest Bootstrap theme as our base theme.  

Test case:

1) Create a menu link for custom-menu
2) Navigate to admin page to view all the menu links
3) Click on edit on the menu link item
4) The Show as Expanded is disabled 

Code (only hook in my .module file):

function mymodule_menu_link_alter(&amp;$item, $menu) {
  if($item['menu'] == 'custom-menu')
  {
    $item['expanded'] = 1;
  }
}
I tried your custom hook call, just to be sure it was called as you imagine, and to see how the $item array was build.

First, according to the hook_menu_link_alter() documentation, their is only one argument to this method in Drupal 7 (&amp;$item).

And when I print the $item element, I can see that the name of the menu of the current element is not 'menu' but 'menu_name'.

Then your code must be something like :

function mymodule_menu_link_alter(&amp;$item) {
  if($item['menu_name'] == 'custom-menu')
  {
    $item['expanded'] = 1;
  }
}


It is an interesting hook, because it is also called when a user add a menu directly from a node form options.