function apachesolr_search_custom_page in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 apachesolr_search.pages.inc \apachesolr_search_custom_page()
- 7 apachesolr_search.pages.inc \apachesolr_search_custom_page()
Returns search results on user defined search pages.
1 string reference to 'apachesolr_search_custom_page'
File
- ./
apachesolr_search.pages.inc, line 11 - Provides the page callback for user defined search pages.
Code
function apachesolr_search_custom_page($page_id, $keys = '', $path_replacer = NULL) {
$search_page = apachesolr_search_page_load($page_id);
if (empty($search_page)) {
drupal_set_message(t('This search page cannot be found'), 'error');
return drupal_not_found();
}
// Add our replacement value in the conditions array
if (!empty($path_replacer)) {
$search_page['settings']['apachesolr_search_path_replacer'] = $path_replacer;
}
// Replace dynamic path with current path
$search_page['search_path'] = str_replace('%', $path_replacer, $search_page['search_path']);
// Retrieve the conditions that apply to this page
$conditions = apachesolr_search_conditions_default($search_page);
// Process our keys so they are clean
$keys = rawurldecode($keys);
// Initiate our build array
$build = array();
// Add a custom search form if required
if (!empty($search_page['settings']['apachesolr_search_search_box'])) {
// Adds the search form to the page.
$build['search_form'] = drupal_get_form('apachesolr_search_custom_page_search_form', $search_page, $keys);
}
// Retrieve the results of the search
$results = apachesolr_search_search_results($keys, $conditions, $search_page);
// Build our page and allow modification.
$build_results = apachesolr_search_search_page_custom($results, $search_page, $build);
$build_output = NULL;
foreach ($build_results as $build_result) {
$build_output .= $build_result;
}
return $build_output;
}