You are here

function apachesolr_multilingual_apachesolr_search_page_alter in Apache Solr Multilingual 6.3

Same name and namespace in other branches
  1. 7 apachesolr_multilingual.module \apachesolr_multilingual_apachesolr_search_page_alter()

Modify the build array for any search output build by Apache Solr This includes core and custom pages and makes it very easy to modify both of them at once

Parameters

array $build:

array $search_page:

File

./apachesolr_multilingual.module, line 936
Multilingual search using Apache Solr.

Code

function apachesolr_multilingual_apachesolr_search_page_alter(array &$build, array $search_page) {
  if (apachesolr_has_searched($search_page['env_id'])) {
    $environment = apachesolr_multilingual_environment_load($search_page['env_id']);
    $settings = $environment['conf']['apachesolr_multilingual_index_settings'];
    if ($settings['apachesolr_multilingual_index']) {
      $languages = apachesolr_multilingual_language_list();
      $filter_languages =& variable_static('apachesolr_multilingual_filter_languages_' . $search_page['page_id']);

      // Retrieve suggestion
      $suggestions = apachesolr_multilingual_get_search_suggestions($search_page['env_id'], $filter_languages);
      if (!empty($suggestions)) {
        $links = array();
        foreach ($suggestions as $language_id => $suggestion) {
          $links[] = (1 == count($filter_languages) ? '' : $languages[$language_id] . ': ') . l($suggestion, $search_page['search_path'] . '/' . $suggestion);
        }
        $build['suggestions'] = theme('apachesolr_search_suggestions', $links);
      }
    }
  }
}