Vylepsena verze stromu kategorii
authorThomas Mudrunka <tomas@mudrunka.cz>
Fri, 9 Dec 2011 20:15:22 +0000 (21:15 +0100)
committerThomas Mudrunka <tomas@mudrunka.cz>
Fri, 9 Dec 2011 20:15:22 +0000 (21:15 +0100)
assistants/category-tree.inc.php

index f268ca774582abc8f482f49c5046ea40e885d608..ce6c4c38043d004ef766263dded0b510e8c1905c 100644 (file)
@@ -16,4 +16,14 @@ foreach($result as $row) {
        addleaf($tree, $row_parts);
 }
 
-print_r($tree);
+function render_tree($tree, $pathindex='__PATH__') {
+       if(!is_array($tree)) return '';
+       $html='<menu>';
+               foreach($tree as $name => $subtree) if($name != $pathindex) {
+                       $html.='<li><b>'.$name.'</b> <small>('.$subtree[$pathindex].')</small>'.render_tree($subtree).'</li>';
+               }
+       $html.='</menu>';
+       return $html;
+}
+echo render_tree($tree);
+//print_r($tree);
This page took 0.105841 seconds and 4 git commands to generate.