In our web (http://www.fundacionalzheimur.org/formacion) we use the structure of the menu primary links, but we haven't found an automatic way of present, as in a book, the child nodes when displaying a menú node.

Our solution is including this php snippet in the node.tpl template, just before the content, in a div floating right:

.... <div class="itemtext">
<!-- Expanded Menu for navigation -->
<?php
 $mid = menu_get_active_nontask_item();
  $active = menu_get_item($mid);
  // this is a top-level link in your primary links
  if($active['pid'] == variable_get('menu_primary_menu', 0)){
    $output.= theme('menu_tree',$mid); 
    	print('<div id="menubox"><h2>navigate</h2>');
	print $output; 
	print('</div>');
  }

?>
<!-- end of menu  -->
    <?php print $content?> 
  </div> .....

The CSS would be:

#menubox {
  display: block;
  float:right;
  width: 35%;
  margin-left: 18px;
  margin-bottom: 18px;
  padding-bottom: 5px;
  background: #fff url(images/Fondo_Logo_menu.jpg) no-repeat bottom right;
 }
 #menubox h2 {
background: #fff  url(images/block-quote_left.gif) no-repeat top left;
color: #6A0D22;
padding: 7px 7px 7px 37px;
margin-bottom: 2px;
line-height: 0.6em;
}

Comments

bengtan’s picture

While surfing, I came across this (apparently) old page. If you have a Drupal 5.x site, you may be interested in submenutree.

donpositivo’s picture

Also available for Drupal 6

gallandv’s picture

I don't know if it's exceedingly complicate, but this is what worked for me to display inside a page just the children (and their childrens and so on) of the current menu item.

    $item = menu_get_item();
    $tree = menu_tree_page_data('primary-links');
    list($key, $curr) = each($tree);

    while ($curr) {
      // Terminate the loop when we find the current path in the active trail.
      if ($curr['link']['href'] == $item['href']) {
        $tree = $curr['below'];
        $curr = FALSE;
      }
      else {
        // Add the link if it's in the active trail, then move to the link below.
        if ($curr['link']['in_active_trail']) {
          $tree = $curr['below'] ? $curr['below'] : array();
        }
        list($key, $curr) = each($tree);
      }
    }
    $menuhtml = theme_menu_tree(menu_tree_output($tree));
    print $menuhtml;
saiprasad kandavalli’s picture

where your code be added

jhchnc’s picture


foreach( $tree as $k => $v ) {
    $thirdLevel = array();  // this will hold third levels as we iterate the tree
    list($key, $curr) = each($v);  // capture current node in tree
    while ($curr) {
      if ( is_array($curr['below']) ) {  // if this node has children
        array_push( $thirdLevel, $curr['below']);  // push them into thirdLevel
        unset( $tree[$key]['below'] );  // unset the child nodes in main tree, so no reuse
        if ( count($thirdLevel) > 0 ) {  //  if there are any children
            foreach( $thirdLevel as $key => $val ) { // we pushed multiples, right
                $links = theme_menu_tree(menu_tree_output($val)); // these get syled within a ul class=menu... good enough hook for me!
                $output .= $links;
            }
        }
        $curr = FALSE;
      }
      else { // well, no children here, so these are second level links
        list($key, $curr) = each($tree);  // capture node
        foreach( $curr as $k => $v ) {
            if ( is_array($v) && $v['href'] ) {  // they aren't all links!
                $output .= '<a href="/'.$v['href'].'">'.$v['title'].'</a>';
            }
        }

      }
    }
}

jhchnc’s picture

and it be added in a custom function you call

md_drupal’s picture

You mentioned custom method. Would you be able to provide the entire flow (template.php, page.tpl.php)?

Thank you!

foxtrotcharlie’s picture

This very flexible module may also do the trick: http://drupal.org/project/menu_block

*****************************
South Africa Drupal Development
*****************************