function google_cse_search_page in Google Custom Search Engine 7.2
Same name and namespace in other branches
- 7.3 google_cse.module \google_cse_search_page()
- 7 google_cse.module \google_cse_search_page()
Implements hook_search_page().
File
- ./
google_cse.module, line 95 - Display a Google Custom Search Engine (CSE) on your site.
Code
function google_cse_search_page($results) {
if (!variable_get('google_cse_use_adv', 0)) {
$output['#theme'] = 'google_cse_results';
return $output;
}
if (!$results) {
// No results found.
$output['search_results'] = array(
'#markup' => theme('google_cse_search_noresults'),
);
return $output;
}
$current_page = 0;
if (!empty($_GET['page'])) {
$current_page = $_GET['page'];
}
$number_results = t('Results @from to @to of @total matches.', array(
'@from' => $current_page * 10 + 1,
'@to' => $current_page * 10 + 10,
'@total' => $GLOBALS['pager_total_items'][0],
));
$output['prefix']['#markup'] = $number_results . '<ol class="search-results">';
foreach ($results as $entry) {
$output[] = array(
'#theme' => 'search_result',
'#result' => $entry,
'#module' => 'google_cse',
);
}
// Important, add the pager.
$output['suffix']['#markup'] = '</ol>' . theme('pager');
return $output;
}