After going though
http://drupal.org/node/78997
(that seems a bit outdated now)
and:
http://drupal.org/node/264216
(I can't get adsense for search work through adsense module)
I decided to start a new thread to crearly outline the necessary steps to make adsense for search work with drupal 5.7.
I must say that my discoverings are almost done, it would be great if you dupal people would help me complete this setup.
1) Go through Google Adsense for Search setup and get the code at the end of the wizard.
1a) Choose to display search results on your own site, and tell Google that search-results.php is the search results page on your site
2) Replace the search box on your site with the one Google provides you with. Mine is similar to the following:
<form action="http://www.example.com/search-results.php" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="partner-pub-1632123456532086:iovbie-cg09" />
<input type="hidden" name="cof" value="FORID:10" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="32" />
<input type="submit" name="sa" value="Search" />
</div>
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=it"></script>
3) create an html page file named search-results.php and place it in the drupal web root. Paste the code Google provides you with in the body of the page you just created. Mine is similar to the following:
<div id="cse-search-results"></div>
<script type="text/javascript">
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "cse-search-box";
var googleSearchFrameWidth = 800;
var googleSearchDomain = "www.google.it";
var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
4) As an option, you may completely disable the search module on your drupal web site
You're done.
I'm not completely satisfied with 3) because it does not take avail of the drupal theming system, I need to statically replicate the look&feel of my website; this means I need to re-edit the file whenever I edit a single bit of my web pages.
======
There is a better solution to 3), unfortunately I can't get it to work! :-)
3-bis) create a new page (drupal content-type), enable "Full HTML" in the Filters, and paste the code Google provides you with in the body field. Mine is similar to the following:
<div id="cse-search-results"></div>
<script type="text/javascript">
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "cse-search-box";
var googleSearchFrameWidth = 800;
var googleSearchDomain = "www.google.it";
var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
In the URL Path field (you need the Path module enabled) enter "search-results.php"
========
This would be great, because the search results page would now be correctly and dynamically themed.
Unfortunately, it doesn't work because the page "search-results.php" is not found by the search box form submit action, it seems to make weird redirects(?!) finally landing to a 404 error (whereas /search-results.php is found when entered directly in the navigation bar).
Hope somebody will help me with 3-bis)
I am sure this would be a great help for all drupalers trying to get Adsense for Search to work with their websites.
:-)
Comments
Finally I made it, with a
Finally I made it, with a quick & dirty trick: I just replaced
with:
Sources:
http://drupal.org/node/78888
http://drupal.org/node/157229
http://www.drupalace.com/blog_entry_fixed_google_web_search_block_2007_0...
What do you think? :-)