You are here

function _adsense_csev2_get_searchbox in Google AdSense integration 7

Generates the CSE v2 search box.

Parameters

string $client: Publisher ID.

int $slot: Slot Id for the AdSense for Search.

Return value

string HTML with the search input form

1 call to _adsense_csev2_get_searchbox()
adsense_display in ./adsense.module
Generates the Google AdSense Ad.

File

cse/adsense_cse.module, line 312
Displays Google AdSense ads on Drupal pages.

Code

function _adsense_csev2_get_searchbox($client, $slot = '') {
  if (variable_get('clean_url', 0)) {
    $results_path = url(ADSENSE_CSE_V2_RESULTS_PATH, array(
      'absolute' => TRUE,
    ));
  }
  else {
    $results_path = $base_url;
  }

  // Add data-queryParameterName because of conflicts with Drupal's 'q' query.
  $output = "<script async src='https://cse.google.com/cse.js?cx=partner-{$client}:{$slot}'></script><div class='gcse-searchbox-only' data-resultsUrl='" . $results_path . '/' . $slot . "' data-queryParameterName='as_q'></div>";
  return $output;
}