function search_api_page_query_has_facets in Search API Pages 7
Determines whether an executed query had any facet filters set.
Parameters
SearchApiQueryInterface $query: The query in question.
Return value
bool TRUE if there are filters with a "facet:*" tag present in the query object, FALSE otherwise.
1 call to search_api_page_query_has_facets()
- search_api_page_search_execute in ./
search_api_page.pages.inc - Executes a search.
File
- ./
search_api_page.pages.inc, line 197 - User page callbacks for the Search pages module.
Code
function search_api_page_query_has_facets(SearchApiQueryInterface $query) {
// Check that the search server supports facets.
$index = $query
->getIndex();
if (module_exists('facetapi') && $index
->server()
->supportsFeature('search_api_facets')) {
// Load the search index's adapter plugin and process the facets.
$adapter = facetapi_adapter_load('search_api@' . $index->machine_name);
$adapter
->processFacets();
// Check if there are any active facets and return a boolean accordingly.
return (bool) $adapter
->getAllActiveItems();
}
// If the search server doesn't support facets, there aren't any facet filters
// set by definition.
return FALSE;
}