Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
31 Jan 2011 at 18:10 UTC
Updated:
14 Feb 2011 at 20:50 UTC
This code is WRONG! (it is not RECURSIVE!)
<?php
function theme_taxonomy_nested_tree($tree) {
if (count($tree)) {
$output = '<ul class="taxonomy-tree">';
foreach ($tree as $term) {
$output .= '<li class="taxonomy-term">';
$output .= l($term->name, taxonomy_term_path($term));
if ($term->children) {
$output .= theme('illogica_category_tree', $term->children);
}
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
?>
This is the RIGHT code:
<?php
function theme_taxonomy_nested_tree($tree) {
if (count($tree)) {
$output = '<ul class="taxonomy-tree">';
foreach ($tree as $term) {
$output .= '<li class="taxonomy-term">';
$output .= l($term->name, taxonomy_term_path($term));
if ($term->children) {
$output .= theme_taxonomy_nested_tree($term->children);
}
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
?>
WRONG: $output .= theme('illogica_category_tree', $term->children);
RIGHT: $output .= theme_taxonomy_nested_tree($term->children); //recurse
Thanks to *you all* for the code!
hope it helps.
SdP
Comments
Comment #1
jhodgdonThis is apparently in response to a comment:
http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module/func...
I've added reply to that comment, pointing to this issue.
Comment #2
SdP commentedYes that was the case.