You are here

function apachesolr_search_search_page_custom in Apache Solr Search 8

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

Mimics apachesolr_search_search_page() but is used for custom search pages We prefer to keep them seperate so we are not dependent from core search when someone tries to disable the core search

Parameters

$results: The results that came from apache solr

$build: the build array from where this function was called. Good to append output to the build array

$search_page: the search page that is requesting an output

2 calls to apachesolr_search_search_page_custom()
apachesolr_search_custom_page in ./apachesolr_search.pages.inc
Returns search results on user defined search pages.
apachesolr_search_search_page in ./apachesolr_search.module
Implements hook_search_page().

File

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

Code

function apachesolr_search_search_page_custom($results, $search_page, $build = array()) {
  if (!empty($search_page['settings']['apachesolr_search_spellcheck'])) {

    // Retrieve suggestion
    $suggestions = apachesolr_search_get_search_suggestions($search_page['env_id']);
    if ($search_page && !empty($suggestions)) {
      $build['suggestions'] = array(
        '#theme' => 'apachesolr_search_suggestions',
        '#links' => array(
          l($suggestions[0], $search_page['search_path'] . '/' . $suggestions[0]),
        ),
      );
    }
  }

  // Retrieve expected results from searching
  if (!empty($results['apachesolr_search_browse'])) {

    // Show facet browsing blocks.
    $build['search_results'] = apachesolr_search_page_browse($results['apachesolr_search_browse'], $search_page['env_id']);
  }
  elseif ($results) {
    $build['search_results'] = array(
      '#theme' => 'search_results',
      '#results' => $results,
      '#module' => 'apachesolr_search',
      '#search_page' => $search_page,
    );
  }
  else {

    // Give the user some custom help text.
    $build['search_results'] = array(
      '#markup' => theme('apachesolr_search_noresults'),
    );
  }

  // Allows modules to alter the render array before returning.
  drupal_alter('apachesolr_search_page', $build, $search_page);
  return $build;
}