function google_cse_preprocess_item_list__search_results in Google Custom Search Engine 8.3
Implements hook_preprocess_item_list__search_results().
File
- ./
google_cse.module, line 80 - Display a Google Custom Search Engine (CSE) on your site.
Code
function google_cse_preprocess_item_list__search_results(&$variables) {
// In the context of Google CSE, we rely on Google to render the content.
// Therefore, we do not want to use Drupal's default list
// (see Drupal\search\Controller\SearchController::view()).
// The simplest way to achieve this in a Drupal context is to
// unset the "items" sent to the list template and render the
// Google CSE results as the 'empty' value.
if (isset($variables['items'][0]['value'])) {
if ($variables['items'][0]['value']['#theme'] == "google_cse_results") {
$variables['empty'] = $variables['items'][0];
unset($variables['empty']['attributes']);
unset($variables['items']);
}
}
}