You are here

function taxo_faceted_navigation_get_menu_tree in Taxonomy Facets 7

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 taxo_faceted_navigation_get_menu_tree()
taxo_faceted_navigation_block_view in ./taxo_faceted_navigation.module
Generate blocks with menu items used for filtering.

File

./taxo_faceted_navigation.module, line 366
Taxo Faceted Navigation module code.

Code

function taxo_faceted_navigation_get_menu_tree($vid) {

  // Get user preferences.
  $do_not_display_if_empty = variable_get('taxo_faceted_navigation_display_link_if_empty', FALSE);
  $do_not_display_if_intersection_empty = variable_get('taxo_faceted_navigation_display_link_if_intersection_empty', FALSE);

  // Get tid for all applied filters from url.
  $terms = taxo_faceted_navigation_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'];
      }
    }
  }

  // Taxonomy tree, get only first level.
  $tree = taxonomy_get_tree($vid, 0, 1, FALSE);
  $menu = _taxo_faceted_navigation_get_menu_tree($vid, $tree, $terms, $do_not_display_if_empty, $do_not_display_if_intersection_empty, $tid_selected, TRUE);
  return theme('taxo_faceted_navigation_ul_wrapper_template', array(
    'ul_sub_menu' => $menu,
  ));
}