Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

i want to expand my theme's primary links, so I put the following code in my custom module.

function mymodulename_menu_link_alter(&$item, $menu) {
  if ($item['menu_name'] == 'primary-links') {
    $item['expanded'] = 1;
  }
}

In page.tpl.php I used print theme('links', $primary_links), but the primary links didn't expand. Why?

share|improve this question

3 Answers

Not really a complete answer, but hook_menu_link_alter() is not called when the menu is rendered; it is called when the menu item is saved. Just an FYI.

share|improve this answer

Try after flushing the menu cache. For that, the Devel module will help you.

share|improve this answer

Start with simple things first. Use the Menu Example in the Examples Project. The menu_example_menu_link_alter() changes a link... You can use it there and experiment easily.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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