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.



How to enable clean urls in 000webhost.com?

000webhost is a famous free web hosting without advertising. Despite its slow loading, this free service can be used to learn cms installation and management. I have already installed drupal on this free hosting package, but there was a small problem. According to drupal message system, this host doesn't support clean urls for drupal 6.x. After browsing a while, I found this simple trick to enable clean urls in 000webhost.

Just follow these steps:
1. Login to your account by simply clicking this link: http://members.000webhost.com/analytics.php?action=login
2. Do the registration (if you are not a member yet), input your domain name, type your password, change "manage analytics code" to disabled code.
3. Edit your .htaccess in drupal, remove "#" from "#RewriteBase /" so it become "RewriteBase /" (without quote)
4. Go to your drupal administration: admin/settings/clean-urls
5. Enabled clean urls
6. See your browser address, there no "?q=" inside drupal url.

All well done now.

ShoutBox

 

Tags

Site Info

Followers

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