“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.”