|
|
||||||||
|
Radio Free Blogistan Always trust content from Blogistan Corporation.
|
|
Fine-tuning Custom Google SearchAfter 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> Here's the resulting search form:
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"> 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"> 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 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! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||