Single level menu block for Drupal
Drupal’s menu system is really flexible and the menu blocks are versatile. Also there are a couple of 3rd party modules to display menus in all kinds of different ways.
There is a module to display a single level menu. But it will only display one menu — I needed two (main and sub).
So here is a quick PHP snippet to display a single level menu from Drupal:
Level 1 links only (no tree)
$level = 0; /* zero-based */ $lvl_menu = menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'), $level); if ($msm == variable_get('menu_primary_menu', 0)) { }
If you don’t want the block to disapear when there is no menu, replace the return with print. I.e.
$level = 0; /* zero-based */ $lvl_menu = menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'), $level); if ($msm == variable_get('menu_primary_menu', 0)) { } print "<br />";
UPDATE: see also the Menu block module.


Comments
Post new comment