You are here

function taxo_faceted_navigation_get_selected_filters in Taxonomy Facets 7

Get all selected filters from the url.

Get the current url, taxonomy terms that are currently applied as filter are in the url, this function examines the url and gets all of the filters applied for the current page.

Return value

array Array of filter arrays, each filter array has all the info about a filter: tid, path alias, term name, vid

3 calls to taxo_faceted_navigation_get_selected_filters()
taxo_faceted_navigation_get_menu_tree in ./taxo_faceted_navigation.module
Print out menu tree for each vocab selected to be taxo faceted filter.
taxo_faceted_navigation_preprocess_node in ./taxo_faceted_navigation.module
Preprocess node url and append argument to it.
taxo_faceted_navigation_print_landing_page in ./taxo_faceted_navigation.module
Print the page that filters are applied to.

File

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

Code

function taxo_faceted_navigation_get_selected_filters() {
  $url = drupal_encode_path($_GET['q']);
  $terms = explode('/', $url);

  // Chop off first term as it is just word used for page callback
  // and its not an actual term.
  $first_url_argument = array_shift($terms);
  $first_argument = variable_get('taxo_faceted_navigation_first_argument', 'items_list');
  $filters = array();
  if ($first_url_argument == $first_argument) {
    $filters = _taxo_faceted_navigation_get_selected_filters($terms);
  }
  else {
    $url_arr = $_GET;
    if (array_key_exists('categories', $url_arr)) {
      $url = drupal_encode_path(check_url($_GET['categories']));
      if ($url) {
        $terms = explode('/', $url);
        $filters = _taxo_faceted_navigation_get_selected_filters($terms);
      }
    }
    else {
      $filters = NULL;
    }
  }
  return $filters;
}