You are here

function apachesolr_search_form_facetapi_realm_settings_form_alter in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 apachesolr_search.module \apachesolr_search_form_facetapi_realm_settings_form_alter()
  2. 6.3 apachesolr_search.module \apachesolr_search_form_facetapi_realm_settings_form_alter()

Implements hook_form_[form_id]_alter().

Adds settings to show facet blocks on non-search pages.

File

./apachesolr_search.module, line 1644
Provides a content search implementation for node content for use with the Apache Solr search application.

Code

function apachesolr_search_form_facetapi_realm_settings_form_alter(&$form, &$form_state) {
  if ('apachesolr' == $form['#facetapi']['adapter']
    ->getId() && 'block' == $form['#facetapi']['realm']['name']) {

    // Gets the environment ID from the searcher, stores in #facetapi property.
    $env_id = ltrim(strstr($form['#facetapi']['adapter']
      ->getSearcher(), '@'), '@');
    $show_facets = apachesolr_environment_variable_get($env_id, 'apachesolr_search_show_facets', 0);
    $facet_pages = apachesolr_environment_variable_get($env_id, 'apachesolr_search_facet_pages', '');
    $form['#facetapi']['env_id'] = $env_id;
    $form['apachesolr_search_show_facets'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show facets on non-search pages.'),
      '#default_value' => $show_facets,
      '#weight' => '-10',
    );
    $form['apachesolr_search_facet_pages'] = array(
      '#title' => t('Non-search paths'),
      '#type' => 'textarea',
      '#default_value' => $facet_pages,
      '#weight' => '-10',
      '#dependency' => array(
        'edit-apachesolr-search-show-facets' => array(
          1,
        ),
      ),
    );
    $form['#submit'][] = 'apachesolr_search_facetapi_realm_settings_form_submit';
  }
}