Home

Primary links

  • top o the deck
  • Drupal for Beginners
  • about
  • links
  • give me some sugar

Drupal stuff

  • EDAM
  • STARDOM
  • Question Bank
  • Drupal musings
  • Drupal tips
Home Blogs Drupalace's blog

Key stuff on this site

Easy Drupal Admin Manual (EDAM)

SEO, Traffic and Revenue: Drupalace's Online Manual (STARDOM)

Drupal for Beginners

Subscribe to posts by RSS or email

Subscribe to Drupal Ace by RSS feed RSS feed 

Subscribe to Drupal Ace by Email

Donate towards my web hosting bill! Get a great host!

Share and save

Share/Save

Random piece of content

Get Found with SEO

Manuals on this site

  • Easy Drupal Admin Manual (EDAM)
    • Welcome to Your Site
    • First Steps: Please Read!
      • Understanding These Instructions
      • Important Terminology!
      • Best Practices for Site Admins
    • Super Quick Guide (for the experienced and the brave)
    • Logging In
    • Your Administrator Tools
    • Setting Site Basics
      • Setting Site Information
      • Configuring Your Theme
    • Creating Content
      • Node Types
      • Create a Page Node
      • Create a Story Node
      • Create a Blog Entry Node
      • Making Images and Other Files Available
      • Using Text and Image Editors
    • Organizing Your Content
      • Terms, Vocabularies, and Taxonomy: "Tagging" Your Content
        • Taxonomy Suggestions
      • Menus, Links, and Paths: Navigating the Site
        • Content Paths and URLs
        • Creating Links
        • Working with Menus: Administration Form (Drupal 6)
        • Working with Menus: Administration Form (Drupal 5)
        • Creating Menu Items on the Fly
        • Placing Menus on Your Pages
      • Placing Content on pages
        • Creating a page from a Single Node
        • Creating a page from a List of Nodes
        • Setting the Front Page
      • Working with Blocks
    • Maintenance Stuff
      • Maintenance and Construction Notices
    • Other Fun Things
      • Changing Color of Garland Theme
      • Free Aliases!
  • SEO, Traffic and Revenue: Drupalace's Online Manual (STARDOM)
    • Set a Clear Goal
    • Make a Good Site
      • Put out the Welcome Mat
      • Make Great Content
      • Build a Great Brand
      • Make Navigation Easy
      • Tune Site Performance
    • Drive Traffic
      • Promote your Site
      • Get Found with SEO
    • Build a Community
      • Build an Offsite Community
    • Monitor and Improve
    • One-Page Checklist
    • Drupal and the Blogging Starter Checklist
      • Drupal and the Blogging Starter Checklist, Part 1
      • Drupal and the Blogging Starter Checklist, Part 2
      • Drupal and the Blogging Starter Checklist, Part 3
      • Drupal and the Blogging Starter Checklist, Part 4
      • Drupal and the Blogging Starter Checklist, Part 5
      • Drupal and the Blogging Starter Checklist, Part 6
      • Drupal and the Blogging Starter Checklist, Part 7

Recent comments

  • Deleting cookies

    Good point; thanks! Deleting cookies and/or caches, depending on the problem at hand, is a part...

  • It worked

    adding $GLOBALS['tempUser'] = $user; worked but I find it worth noting that I had to delete...

  • very good document...

    very good documentation for beginners!!!!!! thanks!!

  • del penitential 62

    strike out abject
    eliminate penitent 5

  • Chat

    Thank you a lot about very beneficial to my work was very useful thank you

more

Fixed: Google web search block

Submitted by Drupalace on Wed, 2007-08-29 13:24
  • article
  • blog post
  • Drupal
  • search
  • trouble

Recap

As described earlier, I've placed many a Google web search block into Drupal sites, using Google AdSense for Search.

https://www.google.com/adsense/search-settings

All to a single end: the blocks don't work. (Hey, consistency counts for something, right?)

As I detailed, both Google and Drupal (even with clean URLs implemented) want to use q in the search parameters toward conflicting ends, resulting in goofiness. One suggested solution is to replace the problematic q in the search code with as_q, something Google and Drupal will both accept but not fight over. (Saintly correspondent jGirlyGirl informs me that query works as well.)

Alas, my problems only half-disappeared: with the code tweak, on-site searches worked fine, but web searches would only return "Your search... did not match any documents."

Hacking...

I hacked much yesterday, trying all sorts of little tweaks to the search code. I then came up with the brilliant strategy I should have thought of weeks ago, which was to check out some sites with working Google search blocks. I even hit upon the perfect candidate: the excellicious 43 Folders site by burgeoning Internet hero Merlin Mann.

http://www.43folders.com

That site not only employs an AdSense for Search block for both on-site and web searches, but it's a Drupal site as well! (Let 43 Folders, not The Onion, be our new poster child for Drupal sites.)

With that specimen laid out before me, I sought to employ the single most valuable technique known to me as a programmer. That's right: copying other people's code.

I viewed the source code for 43 Folders' search results page, and compared with my own. Hmm, 43 keeps the unadorned q in its search parameters; apparently, Merlin solved that problem at the .htaccess level or elsewhere. Yet as_q should still work for me, as it has for many others. I see, too, that 43's code specifies its search results page with a trailing "/", while my code does not. Was that the problem? No, tacking a slash onto the end of the page URL in my code didn't fix things (in action, the slash just gets stripped out of the resulting URL anyway).

And so on. I noted every difference I could find. I even went as far as nabbing 43's search code wholesale and pasting it into my Drupalace search block, changing only the obvious particulars like my domain, my search result page URL, etc. But every variation I tried resulted in some error: either a "Your search... did not match any documents" result or a "page not found" result, for on-site search, web search, or both.

"Why will this same code work for him, but not for me? Aaaarrgggghhh!!!!"

The workable, if gustatorily unsatisfying, solution

In the end, I went back to the Google AdSense setup page, and grabbed fresh code for my block. And it works.

Wait, don't laugh at me yet. Here's the rub:

I earlier pointed out how all my block seemed to work at first, and at some point stopped. I can now elaborate on that. It appears that when I paste fresh code into a block (and change q to as_q), it works – but if I then edit that block again for any reason, the code breaks. And unfortunately, I have to edit the code. First, I need to change the q as above, if I forgot to do so on the first pass. Then I'll see that my on-site search is by default set to the full domain ("www. drupalace.com"), which makes the block too wide, so I'll return to change that to something shorter like "This site". Then I'll say "oh, yeah, I forgot to give the block a heading", so it's back to edit that.

Touch the block, and it breaks. I don't know why. The first suspect is input format – the code will obviously break if I use Filtered HTML or any other format that futzes with the code. But I use an Unfiltered HTML format, which should – and appears to – leave code unmolested (other than stripping line breaks).

So I don't know why editing the block breaks code, even when I only edit, say, the block header and don't touch the code. But I do know now how to make things work:

When I prepare the block, I make all changes at once: paste in the code, change its q to as_q, change its search options to read "This site" instead of the full domain name, and give the whole block a header (if I want one). The I save the block and don't edit it again. If I do have to edit it again, I paste in (and tweak) fresh code at the same time.

Problem ameliorated, if still marred by the above remaining annoyance. And as a denouement to my tale, my solution's a boring one too. But if that lengthy overview helps anyone else with the same issue, I'll be a happy Ace.

 

Share/Save
  • Drupalace's blog
  • Printer-friendly version
  • Quote
Unknown Drupaloid's picture

Re: Fixed: Google web search block

Submitted by Unknown Drupaloid (not verified) on Tue, 2008-11-04 03:49.

Ok, It seems to work for me using PHP Filter, but only if I flag "promote to front page" on the search results page, which makes its title (search results) visible everywhere (obviously...either if no search started).

If I don't flag "promote to front page" on the Search Results page, I get the refreshed home page exactly as I press F5.

Could you tell me how do I fix it?

Thanks

  • reply
  • quote
henns20's picture

Re: Fixed: Google web search block

Submitted by henns20 (not verified) on Wed, 2007-10-10 06:02.

drupalace,

1)thanks foor the article and quick fix to the search problem - it worked for me...don't really understand why but for now i am happy...thx again

2)as for the problem with inserting the code into a block i had many problems when inserting the code into an "Full HTML filter - line and paragraphs break automatically" - the format that was showing on the Adsense for Search was not outputting correctly when inserting it into a block or page

my workable solution: -hacked around and deleted some of the "linespacing" in code because although there are no linebreaks shown in the code in the input box- when copying and pasting the code - the line breaks are shown in the page source

 

  • reply
  • quote
housetier's picture

php input filter

Submitted by housetier (not verified) on Wed, 2007-12-12 23:30.

using the php input filter wouldn't break any lines, would it? and you still can insert html..

  • reply
  • quote
Drupalace's picture

Re: php input filter

Submitted by Drupalace on Fri, 2007-12-14 01:26.

A quick check shows me that using the PHP input filter, with rich text input disabled, results in a solid block of text, no line breaks or anything. So yes, that's an option to keep in mind for anyone who wants to just put in some undecorated text, and for whatever reason is having trouble with other input methods.

The PHP code input format: it isn't just for PHP any more!™

Thanks for the comment!

  • reply
  • quote
Drupalace's picture

Re: Fixed: Google web search block

Submitted by Drupalace on Sun, 2007-10-14 11:29.

I know, inputting code can be tricky at times; even using the right input format, it seems code can be terribly "fragile", breaking for no clear reason. Thanks for the input tip; it may help others having trouble.

  • reply
  • quote
Unknown Drupaloid's picture

Just searches

Submitted by Unknown Drupaloid on Sat, 2010-03-06 02:58.

Drupalace wrote:

I know, inputting code can be tricky at times; even using the right input format, it seems code can be terribly "fragile", breaking for no clear reason. Thanks for the input tip; it may help others having trouble.

 

Test ,e

  • reply
  • quote

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><br><p>
  • You may quote other posts using [quote] tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options


Relevant Content

The Drupal Ace logo has dealt these content suggestions from the deck.

  • It's always something: Google web search blocks don't work!
  • Working with Menus: Administration Form (Drupal 6)
  • Why doesn't Google web search work?
  • It's always something: "Read More" links dropping out
  • Back on track with Node Import
  • Testing Ubercart ecommerce: Please help with missing tabs!
  • Drupal beginner documentation picking up steam

Learn Drupal, hands-on

Get the beginner-friendly ebook that teaches community site building via a live case study.

Drupal 6 Ultimate Community Site Guide

Read the review

Drupal mini tip

Want a quick redirect, without manhandling system files? Just use the core Path module: on the "URL aliases" form (/admin/build/path), complete 'Path alias' with the path you expect visitors to use, and complete 'Existing system path' with the path you'd like to send them. 'Path alias' can be an existing system path; Drupal will still treat it as an alias and send visitors to your specified path.

It's a deal!

Dreamhost dealsDrupal Ace presides over his domain, proudly ensconced in his DreamHost eyrie. Won't you join me?

Promo code deal!

Just enter the code 49ER when you register for an account, and save $49 off the already-low price. No strings!

Read my hosting service review

Powered by Drupal, an open source content management system

Copyright 2007 and forever after. Made with Drupal, of course. On OS X, of course. Served up by DreamHost. DreamHost

RoopleTheme