tags:

views:

684

answers:

4

I'd like to pull out just one section of my navigation menu - a single section of the admin menu structure. I can load the entire navigation menu tree, but I can't see an easy way of pulling out just one segment of it.

Is there an easy way to do this, or do I have to do something hacky?

A: 

Have a look at function menu_navigation_links. You pass it a menu name (default = navigation) and a level (default = 0).

Olav
Thanks, but not what I'm looking for. I need a way to specify a root node for the tree that's not the root. `menu_navigation_links` gives me no way to display only `admin/content` and its children.
ceejayoz
A: 

I'm not sure I entirely understand the situation, but you may want to take a look at Menu Block Split which allows you to split levels of navigation into blocks.

http://drupal.org/project/menu%5Fblock%5Fsplit

robotoverlord
That looks like it might work. Thanks, I'll try it out
ceejayoz
A: 

Not sure if you'd consider this an easy way, but you could try to grab the whole menu tree via menu_tree_data() or menu_tree_page_data(), find and extract the section you're interested in from the resulting tree structure and render the resulting subtree via menu_tree_output().

EDIT: Stumbled over How to rendering a menu subtree in the meantime - looks like my suggestion could work, but I would definitely not consider this being easy ;)

Henrik Opel
A: 

I found this here which works great for me.

<?php
$menus = menu_tree_page_data(menu_get_active_menu_name()); //get menu tree for active menu
  $output='';
  foreach($menus as $data) {
      if(!empty($data['link']['in_active_trail'])){
        $link = theme('menu_item_link', $data['link']);
        $extra_class = NULL;
        if ($data['below']) {
          $output .= theme('menu_item', $link, $data['link']['has_children'], menu_tree_output($data['below']), $data['link']['in_active_trail'], $extra_class);
        }
        else {
          $output .= theme('menu_item', $link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
        }
      }
  }
  return theme('menu_tree', $output);
?>
jsims281

related questions