tags:

views:

140

answers:

2

I really only need the mlid and title text for the first level below a certain menu item. Here's what I'm doing at the moment. (It works, but I suspect there may be a more drupal-y way.):

/**
 * Get all the children menu items below 'Style Guide' and put them in this format:
 * $menu_items[mlid] = 'menu-title'
 * @return array
 */
function mymod_get_menu_items() {
    $tree = menu_tree_all_data('primary-links');
    $branches = $tree['49952 Parent Item 579']['below']; // had to dig for that ugly key
    $menu_items = array();
    foreach ($branches as $menu_item) {
        $menu_items[$menu_item['link']['mlid']] = $menu_item['link']['title'];
    }
    return $menu_items;
}

Is there?

A: 

Have you looked into menu_block module?

http://drupal.org/project/menu_block

Kevin
yeah, I don't want the built menu, just the data...
sprugman
Menu_block has interesting functions to help you.
Brice Favre
A: 
barraponto
that's definitely nicer than mine (assuming the titles are unique), except I think you mean `==` in your `if` statement. :)
sprugman
and wait: I'm not testing this, but `if ($tree???)` shouldn't that maybe be `if ($branch...`
sprugman
yes, it should! i'm correcting it right now, thanks.
barraponto
you still need to correct the `=` => `==` error. :)
sprugman
there it goes...
barraponto
But it don't work for a sub level ?
Brice Favre

related questions