tags:

views:

27

answers:

1

Hi,

How would I trim/ unset a certain number of menu from drupal navigation menu to avoid lengthy menus for a specific page? Say I want to remove the last 20 menu items from navigation menu.

Any advice would be very much appreciated.

Thanks

+1  A: 

You could do it at the theme layer easy enough by theming your menu.

See theme_links()

http://api.drupal.org/api/function/theme_links/6

Perhaps something like:

function mytheme_links($links, $attributes = array('class' => 'links')) {
$length = variable_get('mytheme_menu_length', 22);
$links = array_slice($links, 0, $length);
return theme_links($links, $attributes);
}

There are other ways also. You could hide some with CSS or build the $links array yourself but the menu api doesn't really have an interface for this.

See menu_navigation_links(). http://api.drupal.org/api/function/menu_navigation_links/6

Rimian
Thanks. I just can't make it work by now though.
swan
With your guidance, I met http://drupal.org/node/256187 that answers my need. I have almost given up with array_slice before, but your advice told me to persist. Thanks
swan
Glad I could help!
Rimian

related questions