It's always something: Google web search blocks don't work!
I replaced Drupal's built-in search with Google search on several sites. From my Google AdSense account, I created the AdSense for Search code, and plugged into a Drupal block.
For a while, it seemed to work fine. The user selects whether to search on the web or on the site, inputs the search terms, and hits the button. Appropriate results show up on a "search results" page (which is a regular Drupal Page containing HTML code specified by Google, to catch and display the search results).
But not long ago, it stopped working on all my sites. A search on either the web or the site would only go to my 404 "not found" page. Heading back to Google for fresh code doesn't fix things.
A fix – no, not quite
I looked for solutions in the forums, finding most ideas concentrated in this thread: http://drupal.org/node/78888 . It seems the problem centers around Drupal and Google both using q= for conflicting purposes. (Apparently, the use of clean URLs in Drupal doesn't remove that problem.)
Within there, I tried one of the solutions involving changing q to Q at the .htaccess level. http://drupal.org/node/78888#comment-150786 It apparently works for some, but didn't work for me.
(For any solutions requiring even greater hacking of PHP etc., I'd just as soon ditch the Google web search instead – it's not THAT vital. : ) Really, there should be a clean way to enable Google search without hacking.)
The most promising solution is changing q to as_q in the search parameters. http://drupal.org/node/78888#comment-152368
When I make that change, a search of my site works fine again.
A search on the web, however, now goes to the correct "found" page, but with only this message: "Your search did not match any documents."
Try both searches using my Google search block at upper right. It should work for a search of this site, and not work for a search of the web.
Question
Does anyone have Google Search working on Drupal 5.x, with the search code in a block and the results code in a node, per my attempts? If so, did you use the as_q mod, or any other trick, to get things working?
Please, dear reader, won't you help?













Re: It's always something: Google web search blocks don't work!
I had the same problem a few months back.
Changing the q to query worked for me.
Re: It's always something: Google web search blocks don't work!
Thanks for the suggestion! I played with query, and while that alone didn't fix my trouble, it was interesting to see that query and as_q both seem equally good replacements for the default q. In all my research on the problem, I hadn't come across query as an option.
Your reply prompted me to tackle the problem anew, and in wee hours of the morning, I did solve it. The solution is a little anti-climactic, but I'll note it for posterity and prosperity. Watch for a new post soon.
Thanks again!
Post new comment