Walter asked for the code to add a search box to his blog. I use a tiny PHP script for universal browser compatibility, but there's a Javascript method that will work on any server.
Somewhere in your blog template, include this code to create the search box. This code is customized for Walter's blog; you just need to replace the two mentions of bikefridaywalter with the URL of your own blog.
<form id="b-search" name="b-search" action="http://search.blogger.com/">The result of the above code will look like this:
<input type="text" id="b-query" name="as_q" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="hidden" name="bl_url"
value="http://bikefridaywalter.blogdrive.com/" />
<input type="submit" name="Search" id="b-searchbtn"
value="Search BikeFriday Walter"
onclick="document.forms['b-search'].bl_url.value='http://bikefridaywalter.blogdrive.com/'"
/>
</form>
This code is based on the code for the search box in the Blogger.com navbar and uses Google's Blogsearch search engine. JavaScript is usable on any server. The disadvantage is that many people disable JavaScript on their browsers. This code will work for any blog that Google Blogsearch knows about, not just Blogger.com blogs. Note that if you run a blog with Blogger.com and use the Blogger.com navbar, you already have a search box at the top of your blog.
You can get fancy with the interface if you want and search by author, by tag to create a primitive categorization scheme, and so forth.
Update: This code does not work with the Safari browser. Does the Blogger Navbar search box work when you surf with Safari?
Update 2: There's an easier way to do this that's free of Javascript.
Tags: blogger blogsearch tips tools javascript form code
Is there any way to make this search through "archived" journal entries also? i.e. my livejournal only displays the 20 most recent entries on the page listed, therefore the search function only searches those 20 entries for the desired string.
ReplyDeletejust curious :)
can't get it to work on blogdrive. :( what's the php code?
ReplyDeletespeaking of code, here's what you need to get safari to give you a little blue rss button for your feed in the address bar:
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://bikefridaywalter.blogdrive.com/index.xml" />
obviously you'll need to replace the url with the appropriate one.
Sarah:
ReplyDeleteLivejournal doesn't automatically send pings when you post articles -- hence, Google Blogsearch doesn't know about your Livejournal blog.
I just sent a ping for your blog and I'll try a search in the morning (if I remember) to see what happens.
Walter:
The sample code on the page is specifically for your blog so it should just work by cutting and pasting directly. PHP code requires PHP support -- is there PHP support on Blogdrive?
update: the java code worked in mozilla. i guess safari doesn't like it. oh well. all my fellow mac geeks will be without search capabilities. (and yes, i know we can use camino or explorer or whatever.. but it's so nice to not HAVE to)
ReplyDeletei'm pleased to find that i don't have the problem that sarah does but i also find that it can't find EVERYTHING. for example, i wrote about a bunch of books including tim krabbe's "the rider" and katie alvord's "divorce your car!" a long long time ago. searches for krabbe and divorce pulled up nothing. but it also doesn't just include the stuff on the main page, either, as a search for "book" shows.
btw, php doesn't work on blogdrive as you suspected.
thanks again, r.
Here's a good technique to show a search result inside your blog, without jumping to the search engine.
ReplyDeletehttp://watung.blogspot.com/2006/02/adding-search-to-my-blog.html
short and straight forward...athnx
ReplyDeleteHi, used the updated version, but both work great, thanks for the hack and the alternative reference!
ReplyDeleteThanks a million for a simple, effective resolution.
ReplyDelete