function apachesolr_search_preprocess_search_results in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 apachesolr_search.module \apachesolr_search_preprocess_search_results()
- 7 apachesolr_search.module \apachesolr_search_preprocess_search_results()
@todo Make sure the paging works for Drupal 6
Parameters
type $variables:
Return value
type
File
- ./
apachesolr_search.module, line 1614 - 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['type'] == '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;
}
$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');
// Add template hints for environments
if (!empty($env_id)) {
$variables['theme_hook_suggestions'][] = 'search_results__' . $variables['type'] . '__' . $env_id;
// Add template hints for search pages
if (!empty($variables['search_page']['page_id'])) {
$variables['theme_hook_suggestions'][] = 'search_results__' . $variables['type'] . '__' . $variables['search_page']['page_id'];
// Add template hints for both
$variables['theme_hook_suggestions'][] = 'search_results__' . $variables['type'] . '__' . $env_id . '__' . $variables['search_page']['page_id'];
}
}
}
}