
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 1.16 KB | hits: 15 | expires: Never
function termpage_nav($term, $settings){
// the trail is the collection of terms that connect the top level to
// the currently active term
$trail = $term ? array_reverse(taxonomy_get_parents_all($term->tid)) : array();
// the settings specific to this block
$vid = $settings[TERMPAGE_SETTINGS_VID];
$max_depth = $settings[TERMPAGE_SETTINGS_MAXDEPTH];
// the depth in the tree of the currently active term
// - 1 to match the depth starting at 0 in the for loop
$current_depth = count($trail) - 1;
// the collection of terms that make up the trail. One term per level
$levels = array();
// variable used for taxonomy_get_tree
$parent = 0;
// depth 0 means first level
for($depth = 0; $depth < $max_depth; $depth += 1){
$current = taxonomy_get_tree($vid, $parent, 1);
// some additional info for the template
termpage_add_alias($current);
$active = $depth <= $current_depth ? $trail[$depth]->tid : null;
$parent = $active;
$levels[$depth] = array(
'terms' => $current,
'active' => $active,
);
}
return $levels;
}