4

I am creating a series of menus in a custom module. This site also has a custom theme. Is there a way in the theme, or in the module, to set a menus "Show as expanded" to true. This way, if I move my site, uninstall, or whatever, it comes back the way it should right out of the box.

2 Answers 2

2

I couldn't find it anywhere on the Drupal documentation, but adding

expanded: TRUE

in the module.links.menu.yml file works.

-1

According to Drupal API for hook_menu:

"expanded": Optional. If set to TRUE, and if a menu link is provided for this menu item (as a result of other properties), then the menu link is always expanded, equivalent to its 'always expanded' checkbox being set in the UI.

So while writing your custom hook simply add expanded option.

$items['examples/page_example'] = array(
    'title' => 'Page Example',
    'page callback' => 'page_example_description',
    'access callback' => TRUE,
    'expanded' => TRUE,
  ); 
1
  • 2
    The question seems to be for Drupal 8, but your answer is specific to Drupal 7.
    – mradcliffe
    May 5, 2016 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.