Tiffany B. Brown

a mish-mosh of stuff

“Sitewide Search On A Shoe String” — now with pages!

Building on the work of Christian Heilmann,* and his SITESEARCH 1.0, I present a modified version of his site search script that supports paginated results.

What do you have to do differently to make this work?

The good news is not much :-) . The major difference is the form and added HTML markup.

<form id="customsearch" action="index.html" method="get">
<div id="cssrchdiv">
	<input type="text" name="p" id="term" value="">
	<input type="hidden" name="vs" id="site" value="YOURDOMAINNAME.COM">
</div>
<p>
<button type="submit">Go</button>
</p>
</form>
<!--/search_form -->
<div id="search_results"></div>

In Christian’s example, he set the form’s action to http://search.yahoo.com/search. It works beautifully if you are serving one page of results. But for our purposes, we are going to reload the current search page, parse the query string, and execute the search. That’s also why we need to add a method to the form — “GET” — so that the form’s values get appended to the URL.

I also added a search_results div so that we can inject the results into a containing div (in case you need to integrate it into an existing site design).

The script is released under a BSD license.

And by “building on,” I mean “straight jackin’ it and adding a few more lines of code.”

  • http://wait-till-i.com/ Chris Heilmann

    Good catch Tiffany! There's also a point that in the BOSS results you have a prevurl and nexturl parameter in the results. this means you can build your own pagination easily. I am coming to Atlanta soon for GA Tech hack day by the way – 1st to 8th of March :)

  • http://wait-till-i.com Chris Heilmann

    Good catch Tiffany! There's also a point that in the BOSS results you have a prevurl and nexturl parameter in the results. this means you can build your own pagination easily. I am coming to Atlanta soon for GA Tech hack day by the way – 1st to 8th of March :)

  • http://intensedebate.com/people/tiffanybbrown tiffanybbrown

    But that would require reading the docs Chris and PFFFT! Who has time to do that? :)

    I weighed the pluses and minuses and did this in about an hour. I wanted the URL to be "hackable" — users could build their own query string in the address bar. I guess that could be done by just setting the method to "GET" … hmmm, I need to tinker some more.

    Would you be available for a beer while you're here?

  • http://intensedebate.com/people/tiffanybbrown tiffanybbrown

    But that would require reading the docs Chris and PFFFT! Who has time to do that? :)

    I weighed the pluses and minuses and did this in about an hour. I wanted the URL to be "hackable" — users could build their own query string in the address bar. I guess that could be done by just setting the method to "GET" … hmmm, I need to tinker some more.

    Would you be available for a beer while you're here?

  • Greg Minter

    Just a question…think I have this working, but I seem to get more results than I want…I want to limit my results from a portion of a tree (e.g. http://www.foo.com/justthisdirectory/.

    How can I do that?

  • Greg Minter

    Just a question…think I have this working, but I seem to get more results than I want…I want to limit my results from a portion of a tree (e.g. http://www.foo.com/justthisdirectory/.

    How can I do that?

    • http://intensedebate.com/people/tiffanybbrown tiffanybbrown

      I think it's a matter of adjusting the value of your domain to be foo.com/justthisdirectory/, but I haven't tried that yet.

  • http://intensedebate.com/people/tiffanybbrown tiffanybbrown

    I think it's a matter of adjusting the value of your domain to be foo.com/justthisdirectory/, but I haven't tried that yet.