You are here

public function SearchApiViewsFacetsBlockDisplay::options_form in Search API 7

Provide the default form for setting options.

Overrides views_plugin_display_block::options_form

File

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

Class

SearchApiViewsFacetsBlockDisplay
Plugin class for displaying search facets in a block.

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  if (substr($this->view->base_table, 0, 17) != 'search_api_index_') {
    return;
  }
  switch ($form_state['section']) {
    case 'linked_path':
      $form['#title'] .= t('Search page path');
      $form['linked_path'] = array(
        '#type' => 'textfield',
        '#description' => t('The menu path to which search facets will link. Leave empty to use the current path.'),
        '#default_value' => $this
          ->get_option('linked_path'),
      );
      break;
    case 'facet_field':
      $form['facet_field'] = array(
        '#type' => 'select',
        '#title' => t('Facet field'),
        '#options' => $this
          ->getFieldOptions(),
        '#default_value' => $this
          ->get_option('facet_field'),
      );
      break;
    case 'use_more':
      $form['use_more']['#description'] = t('This will add a more link to the bottom of this view, which will link to the base path for the facet links.');
      $form['use_more_always'] = array(
        '#type' => 'value',
        '#value' => $this
          ->get_option('use_more_always'),
      );
      break;
    case 'hide_block':
      $form['hide_block'] = array(
        '#type' => 'checkbox',
        '#title' => t('Hide block'),
        '#description' => t('Hide this block, but still execute the search. ' . 'Can be used to show native Facet API facet blocks linking to the search page specified above.'),
        '#default_value' => $this
          ->get_option('hide_block'),
      );
      break;
  }
}