Fine-tuning Custom Google Search

After experimenting with a few approaches for adding a Google search box to Radio Free Blogistan (with the help of my readers), I found a satisfactory method. I'm posting the code in this story format so that I can refer to it in a blog post without actually putting the code out there and screwing up people's aggregators.

First of all, I set up a free custom search account with Google (in order to get co-branding on the results page, and because the first example I tried to adapt was done that way).

Google supplies a code example that includes a radio-button option for choosing between searching just the site or searching the whole web. I tweaked it a little without changing the functionality (just the labels on the button and radio-button choices):

<FORM method=GET action=http://www.google.com/custom>;
<A HREF=http://www.google.com/search>;
<IMG SRC=http://www.google.com/logos/Logo_40wht.gif border=0 ALT=Google align=middle></A> <INPUT TYPE=text name=q size="10" maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Just Goog It!">
<INPUT type=hidden name=cof VALUE="GIMP:darkblue;LW:380;ALC:red;L:http://blogs.salon.com/0001111/images/rfbanner.jpg;GFNT:lightblue;LC:red;LH:100;AH:left;VLC:gray;S:http://blogs.salon.com/0001111/;GALT:blue;AWFID:ba6ecf243ae3d16f;"><br />
>span class="small">
<input type=radio name=sitesearch value="blogs.salon.com" checked>Search blogs.salon.com
<input type=radio name=sitesearch value="">Search the Web</span><br />
</FORM>

Here's the resulting search form:

Google
Search blogs.salon.com Search the Web

The problem with this approach is that it searched blogs.salon.com (all Salon blogs), not just RFB. (It works just fine, though, if your blog's address is at the root of a domain name.) After I whined about this on my blog, Ian Landsman sent me code that will search just Radio Free Blogistan:

<form action="http://www.google.com/search" method="get">
<input type="text" name="q" size="10">
<input type="submit" value="Just Goog It!">
<input type="hidden" name="hl" value="en">
<input type="hidden" name="ie" value="ISO-8859-1">
<input type="hidden" name="as_qdr" value="all">
<input type="hidden" name="q" value="site:salon.com">
<input type="hidden" name="q" value="inurl:0001111">
</form>

The resulting search form does the trick:

The only drawback is that it doesn't include the co-branding and it doesn't offer another crack at searching just RFB after delivering the first page of results. These really aren't big issues and the solution would be satisfactory, but I wanted to see if I could have my cake and eat it too, so I slammed together the two code examples and tried to make a hybrid version that used my custom Google account but still focused on just my site and not all of Salon blogs.

Here's what I came up with:

<form method="get" action="http://www.google.com/custom">
<input type="text" name="q" size="10" maxlength="255">
<input type="submit" name="sa" VALUE="Just Goog It!">
<input type="hidden" name="hl" value="en">
<input type="hidden" name="ie" value="ISO-8859-1">
<input type="hidden" name="as_qdr" value="all">
<input type="hidden" name="q" value="site:blogs.salon.com">
<input type="hidden" name="q" value="inurl:0001111">
<input type="hidden" name="cof" VALUE="GIMP:darkblue;LW:380;ALC:red;L:http://blogs.salon.com/0001111/images/rfbanner.jpg;GFNT:lightblue;LC:red;LH:100;AH:left;VLC:gray;S:http://blogs.salon.com/0001111/;GALT:blue;AWFID:ba6ecf243ae3d16f;">
</form>

Because I didn't know precisely what each element does, I was as conservative as possible, which may mean that there are some unnecessary elements in the above example. This is blind hackery, not sophisticated understanding of Google's format.

Here's the resulting search form:

This one works about as well as can be expected. It may be a little confusing for users trying to search again from the results page (because of the site:blogs.salon.com inurl:0001111 that shows up pre-supplied in the search box and must not be deleted if the next search is to be limited to just RFB), but what do you want for free?

I'm now going to replace the calendar on my home template with this search box and include a link to this story for anyone who wants to take advantage of what I've learned.

Please feel free to steal any of the code, but if you do use the custom-search approach, be sure to set up your own account and use your own logo and color choices for the co-branding effects!

Radio Free Blogistan
ad blaugeam
Last updated:
10/25/02; 7:16:07 PM

October 2002
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Sep   Nov


Categories:
Blogistan
metablog
knowhow
syllabus
memewatch
fireweaver
radioactive
outspoken
salonika
x-pollen

All Headlines


Blogroll Me, Daddy!
Eight to the Bar



Buy 'Dreamweaver Savvy' at Amazon!


Subscribe to this blog in Radio:
Subscribe to "Radio Free Blogistan" in Radio UserLand.
Click to see the XML version of this web page.

© Copyright 2002 Christian Crumlish (xian) . Click here to send an email to the editor of this weblog.
Last update: 10/25/02; 7:16:07 PM .



E-mail me here: Christian Crumlish (xian) :
Click here to send an email to the editor of this weblog.