function apachesolr_search_preprocess_search_results in Apache Solr Search 8
Same name and namespace in other branches
- 6.3 apachesolr_search.module \apachesolr_search_preprocess_search_results()
- 7 apachesolr_search.module \apachesolr_search_preprocess_search_results()
File
- ./
apachesolr_search.module, line 1466 - Provides a content search implementation for node content for use with the Apache Solr search application.
Code
function apachesolr_search_preprocess_search_results(&$variables) {
// Initialize variables
$env_id = NULL;
// If this is a solr search, expose more data to themes to play with.
if ($variables['module'] == 'apachesolr_search') {
// Fetch our current query
if (!empty($variables['search_page']['env_id'])) {
$env_id = $variables['search_page']['env_id'];
}
$query = apachesolr_current_query($env_id);
if ($query) {
$variables['query'] = $query;
$variables['response'] = apachesolr_static_response_cache($query
->getSearcher());
}
if (empty($variables['response'])) {
$variables['description'] = '';
return NULL;
}
$total = $variables['response']->response->numFound;
$params = $variables['query']
->getParams();
$variables['description'] = t('Showing items @start through @end of @total.', array(
'@start' => $params['start'] + 1,
'@end' => $params['start'] + $params['rows'] - 1,
'@total' => $total,
));
// Redefine the pager if it was missing
pager_default_initialize($total, $params['rows']);
$variables['pager'] = theme('pager', array(
'tags' => NULL,
));
// Add template hints for environments
if (!empty($env_id)) {
$variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module'] . '__' . $env_id;
// Add template hints for search pages
if (!empty($variables['search_page']['page_id'])) {
$variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module'] . '__' . $variables['search_page']['page_id'];
// Add template hints for both
$variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module'] . '__' . $env_id . '__' . $variables['search_page']['page_id'];
}
}
}
}