Project:SiteMenu
Version:5.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

I'd like to contribute the following implementation of this function.

  • It outputs an empty term as expanded rather than a leaf (which I think, should just be for nodes)
  • It seem to run in half the time of the original, (though run time varies substantially for both)
  • I have found it easier to add other links -- ie a link to timeline only on 'expanded' items that contain 'leaf's
  • Alway closes <li>'s as well as <ul>'s even when depth >= 2 at end

If someone is interested -- please review.

<?php
function theme_sitemenu_render_outline($tree, $vocab_type) {
 
$old_depth = -1;
 
$path_type = array('taxonomy/term/', 'image/tid/', 'forum/');
 
$output = "";
  foreach(
$tree as $term) {
    if ((
$delta = $term->depth - $old_depth) <> 0) {
     
$output .= str_repeat(($delta > 0) ? '<ul class="menu">': '</ul></li>', abs($delta))."\n";
    }
   
$old_depth = $term->depth;
   
$output .= ((isset($term->link)) ?
     
"<li class=\"leaf\">$term->link</li>"// This is a node
     
"<li class=\"expanded\">".l($term->name . (($term->count) ? ' (' . $term->count . ')' : ''),
           
$path_type[$vocab_type] . $term->tid, array ("title" => $term->description)));
  }
  return
$output . str_repeat('</ul></li>', $old_depth)."</ul>\n";
}
?>
nobody click here