I have a Solaris box hosting 3 websites, each of which has a unique
swish-e index file. I'd like to make a SELECT box that will look
something like this:
<select name="si">
<option value="">Search All Sites
<option value="0">Search Corporate Site
<option value="1">Search Customer Site
<option value="2">Search Support Site
</select>
The idea here is that customers can choose to search through the
contents of a single site, or select NO index in order to search
through all sites.
To accomplish that, I made a select_indexes directive like this in my
.swishcgi.conf file:
select_indexes => {
description => 'Select Something: ',
default_index => [ qw(
/usr/local/lib/swish-e/indexes/site1.index
/usr/local/lib/swish-e/indexes/site2.index
/usr/local/lib/swish-e/indexes/site3.index
)]
}
That way, the default index is actually all 3 indexes. (I don't have
any method, columns, labels, etc. directives in the select_indexes hash
because I'm creating my own search page using the HTML code listed
above).
Now this idea works fine if I'm using, say, checkboxes. e.g.
<input type="checkbox" name="si" value="0">Search Corporate Site
<input type="checkbox" name="si" value="1">Search Corporate Site
<input type="checkbox" name="si" value="2">Search Corporate Site
If no checkboxes are selected, no "si" variable gets passed into
swish.cgi, and the default_index(es) kick in just like I want.
However, if I use the <SELECT> box code listed at the top of this page
(and select "Search All Sites"), then the code breaks, and I get a
"Index file error: Could not open the index file 'index.swish-e': No
such file or directory" error.
I've discovered this is because selecting a "null" value <option> in a
<select> box creates a GET request that contains "si=" . The Perl CGI
module interprets this as a null value, and dutifully populates the
"si" array with a single (null) value. And that's not the same thing
as having NO "si" value at all. Since "si" has a null value, swish-e
doesn't bother using the default_index(es).
My kludge to work around this so far has been to edit swish.cgi (2.4.0
release version) and change line 1382 from:
if ( !@choices ) {
to:
if ( !@choices || ($#choices == 0 && !$choices[0])) {
It's a ugly hack, but at the moment it's the only way I know how to
accomplish what I want to do. Does anyone have a better suggestion how
I could tackle this problem?
Thanks!
=====
=-=-= David =-=-=
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
Received on Tue Nov 18 23:58:29 2003