I Dig It: htdig search & ssi

When it comes to usability and information architecture, there is just no replacement for a good search engine on your site. Try as you might to design an intuitive navigation scheme, let’s face it…one size never fits all. But no need to fear…your search engine can add an alternative way for folks to find what they so desparately seek.

In my world (UT Austin), I’ve got two obvious choices for search engines, Google Free University Search and htdig. While Google is sweet, I can’t customize the results page, so google doesn’t meet my needs. So, I turn to my good ole friend, htdig. But unlike other sites where I’ve implemented htdig, the site I’m working with now stretches across two different servers and is virtually hosted as well. Creating the results page header and footer proved to be a challenge because (horrors), htdig wouldn’t let me use server side includes (ssi) . Ouch!

I toyed with the idea of writing the results page in PHP but was convinced that if I thought creatively enough, I could trick htdig into letting me use ssi. And after a few bumps and bruises I won the battle. So, in case you’ve got a yearnin’ for ssi in your htdig results page, here is what I learned yesterday.

Ingredients:

  • plain ole html search form using get with the action set to a dynamic results page
  • dynamic results page with a suffix of .html
  • .htacess file instructing your server to parse .html for ssi
  • and your usual header.html and footer.html

1) Set your search form vars as follows:

<form method="get" action="results.html">
<input type="hidden" name="config" value="nameofyourconf" />
<input type="hidden" name="restrict" value="" />
<input type="hidden" name="exclude" value="" />
<label for="words" class="headline">Search XYZ site:
<input type="text" size="30" name="words" id="words" value="" />
<input type="submit" value="Search" />
</form>

Note: the method is get and the action is pointing to your dynamic html results page.

2) dynamic results page – use

<!--#include virtual="foo.html"-->
to dynamically bring in elements

3) create an .htaccess file that includes:
AddType text/html .html
AddHandler server-parsed .html

4) Create your htdig custom header.html and footer.html and set your conf (htdig config) to use these files. Just remember that you can not use ssi in these two files because htdig won’t process it…and htdig currently requires that these files be html files. No shtml or php versions of the header or footer allowed!

And for your coding pleasure, a working sample.

2 comments

  1. Nice “how to” Glenda. I shied away from Google for a long time for the same reason. I wasn’t terribly happy with the results we were getting from htdig, but I wanted the customization and I didn’t think Google offered that option.

    FWIW, it turns our you CAN customize the Google results page. Just sign up for your own public service search account, and you can specify your own header and footer (x)html/css via a web form. According to thier FAQ, “Multiple departments and organizations within the same organization can sign up for Google’s Public Service Search program.”

    You can see an example of the results by searching Be a Longhorn.

    Michael

  2. Sweeeeet! So, I take it you signed up for the public service search account specifically for the bealonghorn.utexas.edu account. I’m wondering how hard it will be to convince them that blantonmuseum.org is part of http://www.utexas.edu. Oh well…can’t find these things out unless you try!

Comments are closed.