You are here

public function SearchApiViewsFacetsBlockDisplay::query in Search API 7

Inject anything into the query that the display handler needs.

Overrides views_plugin_display::query

File

contrib/search_api_views/includes/display_facet_block.inc, line 154
Display plugin for displaying the search facets in a block.

Class

SearchApiViewsFacetsBlockDisplay
Plugin class for displaying search facets in a block.

Code

public function query() {
  parent::query();
  $facet_field = $this
    ->get_option('facet_field');
  if (!$facet_field) {
    return NULL;
  }
  $base_path = $this
    ->get_option('linked_path');
  if (!$base_path) {
    $base_path = $_GET['q'];
  }
  $limit = empty($this->view->query->pager->options['items_per_page']) ? 10 : $this->view->query->pager->options['items_per_page'];
  $query_options =& $this->view->query
    ->getOptions();
  if (!$this
    ->get_option('hide_block')) {

    // If we hide the block, we don't need this extra facet.
    $query_options['search_api_facets']['search_api_views_facets_block'] = array(
      'field' => $facet_field,
      'limit' => $limit,
      'missing' => FALSE,
      'min_count' => 1,
    );
  }
  $query_options['search_api_base_path'] = $base_path;
  $this->view->query
    ->range(0, 0);
}