function taxonomy_facets_get_menu_tree in Taxonomy Facets 7.2
Same name and namespace in other branches
- 8 taxonomy_facets.module \taxonomy_facets_get_menu_tree()
- 7.3 taxonomy_facets.module \taxonomy_facets_get_menu_tree()
Print out menu tree for each vocab selected to be taxo faceted filter.
For each vocabulary id that is passed as an argument output menu tree. Array of menu tree is passed through the theme function at the end, so themed output is produced.
Parameters
integer $vid: Vocabulary id
Return value
string Themed menu tree.
1 call to taxonomy_facets_get_menu_tree()
- taxonomy_facets_block_view in ./
taxonomy_facets.module - Generate blocks with menu items used for filtering.
File
- ./
taxonomy_facets.module, line 432 - Taxo Faceted Navigation module code.
Code
function taxonomy_facets_get_menu_tree($vid) {
// Get tid for all applied filters from url.
$terms = taxonomy_facets_get_selected_filters();
$tid_selected = '';
if ($terms) {
foreach ($terms as $term) {
if ($term['vid'] == $vid) {
// If term is from this vocabulary, it means it is currently
// selected term for this vocabulary.
$tid_selected = $term['tid'];
}
}
}
// Begin menu tree by adding "Filter applied:" at the top, with the right filter
// and option to remove it
$menu = '';
if ($tid_selected) {
$menu_record = array();
$menu_record['tid'] = '';
$term_name = taxonomy_facets_get_term_name_from_id($tid_selected);
$menu_record['term name'] = $term_name['name'];
$menu_record['url alias'] = taxonomy_facets_build_url_alias($vid, $terms, NULL);
$menu_record['menu item class'] = 'first leaf';
$menu_record['active'] = '';
$menu .= theme('taxonomy_facets_removefilter_template', array(
'taxo_menu_item' => $menu_record,
));
}
// Taxonomy tree, get only first level of the taxonomy hierarhy
$tree = taxonomy_get_tree($vid, 0, 1, FALSE);
// Pass in the first level of the hierarhy tree, this function will call
// itself recursively and display other sub levels in each subsequent call
// to itself. Eventualy the wholee tree will be build in the $menu variable
$menu .= _taxonomy_facets_get_menu_tree($vid, $tree, $terms, $tid_selected, TRUE);
return theme('taxonomy_facets_ul_wrapper_template', array(
'ul_sub_menu' => $menu,
));
}