You are here

function taxonomy_facets_get_selected_filters in Taxonomy Facets 7.2

Same name and namespace in other branches
  1. 8 taxonomy_facets.module \taxonomy_facets_get_selected_filters()

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 taxonomy_facets_get_selected_filters()
taxonomy_facets_get_menu_tree in ./taxonomy_facets.module
Print out menu tree for each vocab selected to be taxo faceted filter.
taxonomy_facets_preprocess_node in ./taxonomy_facets.module
Preprocess node url and append argument to it.
taxonomy_facets_print_landing_page in ./taxonomy_facets.module
Print the page that displays list of nods when filters are applied.

File

./taxonomy_facets.module, line 330
Taxo Faceted Navigation module code.

Code

function taxonomy_facets_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, but we will need it for checks so put it in to
  // the variable
  $first_url_argument = array_shift($terms);
  $first_argument = variable_get('taxonomy_facets_first_argument', 'items_list');
  $filters = array();

  // If first argument was reserved word as per settings it means we are on the filtering page
  if ($first_url_argument == $first_argument) {
    $filters = _taxonomy_facets_get_selected_filters($terms);
  }
  else {
    $filters = NULL;
    if (array_key_exists('categories', $_GET)) {
      $url = drupal_encode_path(check_url($_GET['categories']));
      if ($url) {
        $terms = explode('/', $url);
        $filters = _taxonomy_facets_get_selected_filters($terms);
      }
    }
  }
  return $filters;
}