Rabu, 23 Desember 2009

Manually Install Adsense for Search in Drupal

I have already installed drupal 6 in my server and want to add Adsense for Search, but I have to face a problem, because Google search results not works properly in my search page. In fact, Google Adsense internal search code still does not work with Drupal sites normally. The reason is Drupal and Google use the same character "q" within $_GET[q] variable. $_GET[q] means "current page" for Drupal and "search query" for Google. We can fix it with two easy steps.

To fix the problem, just follow these 3 simple steps:

Step 1:
Create a custom page like "googlesearch" or something else under Drupal, then add Adsense Code for results page inside "googlesearch page.

Step 2:
Add this code at the top of your Drupal's index.php:
// Solve Drupal-Adsense for Search problem
$_GET[q] = ($_GET['cx']) ? "googlesearch" : $_GET[q] ;

Step 3:
Type some key words in Google Search box, and see the results.



0 komentar:

Posting Komentar

ShoutBox

 

Tags

Site Info

Followers

Indie Drupalist Copyright © 2009 Blogger Template Designed by Bie Blogger Template