function recipe_build_index in Recipe 5
Recursively traverses the term tree to construct the index.
Return value
string the output for this tree.
1 call to recipe_build_index()
- recipe_index in ./
recipe.module - Constructs the recipe index page, using theme functions.
File
- ./
recipe.module, line 1089 - recipe.module - share recipes for drupal 5.x
Code
function recipe_build_index(&$tree, $parent_url) {
$output = '';
if ($tree == array()) {
return '';
}
do {
$cur = current($tree);
$nex = next($tree);
if ($nex === false) {
$next_depth = -1;
}
else {
$next_depth = $nex->depth;
}
$cur->link = $parent_url . '/' . urlencode(strtolower(trim($cur->name)));
$cur->children = '';
if ($next_depth > $cur->depth) {
$cur->children = recipe_build_index($tree, $cur->link);
// sync $next_depth, because 'next item' may be shoved forward
// Thanks for the patch Roderik.
$nex = current($tree);
if ($nex === false) {
$next_depth = -1;
}
else {
$next_depth = $nex->depth;
}
}
$cur->count = module_invoke('taxonomy', 'term_count_nodes', $cur->tid);
$output .= theme('recipe_index_item', $cur);
} while ($cur->depth == $next_depth);
return theme('recipe_list', $output);
}