function taxonomy_menu_block_structure_tree in Taxonomy menu block 7
Structure tree with only the info we need.
1 call to taxonomy_menu_block_structure_tree()
- taxonomy_menu_block_get_taxonomy in ./
taxonomy_menu_block.module - Get taxonomy tree & name, taking into account i18n.
File
- ./
taxonomy_menu_block.module, line 423 - Taxonomy Menu Block module allows you to make menu blocks out of your taxonomies in a very performant way.
Code
function taxonomy_menu_block_structure_tree($data, $vid, $lang = NULL) {
$tree = array();
foreach ($data as $term) {
// If one term in a localized taxonomy isn't translated all terms get
// returned without a depth or a parent, giving us unusable results.
// We leave those out here.
if (isset($term->depth)) {
$branch['name'] = $term->name;
// Get path here as it requires an extra db query.
// This way we get it in cache.
$branch['path'] = drupal_get_path_alias('taxonomy/term/' . $term->tid, $lang);
$branch['depth'] = $term->depth;
$branch['parents'] = $term->parents;
$branch['active_trail'] = '0';
// Set alias option to true so we don't have to query for the alias every
// time, as this is cached anyway.
$branch['link_options'] = array(
'alias' => TRUE,
);
$tree[$term->tid] = $branch;
}
}
// Let other modules alter the tree data before it gets cached.
drupal_alter('taxonomy_menu_block_tree', $tree, $vid);
return $tree;
}