public function CseResultsController::display in Google AdSense integration 8
Display the search results page.
Return value
array Markup for the page with the search results.
1 string reference to 'CseResultsController::display'
File
- src/
Controller/ CseResultsController.php, line 46
Class
- CseResultsController
- Controller for the Custom Search Engine results page.
Namespace
Drupal\adsense\ControllerCode
public function display() {
$config = $this
->config('adsense.settings');
$width = $config
->get('adsense_cse_frame_width');
$country = $config
->get('adsense_cse_country');
if ($config
->get('adsense_test_mode')) {
$content = [
'#theme' => 'adsense_ad',
'#content' => [
'#markup' => nl2br("Results\nwidth = {$width}\ncountry = {$country}"),
],
'#classes' => [
'adsense-placeholder',
],
'#width' => $width,
'#height' => 100,
];
}
else {
global $base_url;
// Log the search keys.
$this
->getLogger('AdSense CSE v1')
->notice('Search keywords: %keyword', [
'%keyword' => urldecode($this->requestStack
->getCurrentRequest()->query
->get('q')),
]);
$content = [
'#theme' => 'adsense_cse_results',
'#width' => $width,
'#country' => $country,
// http://www.google.com/afsonline/show_afs_search.js
'#script' => $base_url . '/' . drupal_get_path('module', 'adsense') . '/js/adsense_cse-v1.results.js',
];
}
return $content;
}