Skip to main content.
home | support | download

Back to List Archive

Re: swish.cgi changes

From: Nathan Vonnahme <nathan.vonnahme(at)not-real.bannerhealth.com>
Date: Thu Jun 19 2003 - 17:33:41 GMT
after the hash definition in .swishcgi.conf, or in swish.cgi after you read the config in from the file, you can do arbitrary things with individual elements, something like this:

       # Example config file -- returns a hash reference
       $c = {
           title           => 'Search Our Site',
           swish_index     => 'index.web',

           template => {
            package         => 'TemplateToolkit',
            file            => 'search.tt',
            options         => {
                INCLUDE_PATH    => '/home/user/swish-e/example',
            },
       };

      $c->{swish_index} = "foo" if $cookie{foo};

      $c;
        

that last line will make the config file still return the doctored up hash reference.
You may need to 'use CGI' in that file and create a new cgi query object, I don't know

For simplish things you could also use the conditional operator inside the hashref:
    title  =>  ((localtime)[3] == 1 ? 'happy first day of the month' : 'search our site'),

I don't know if you need those outer parentheses but I think you do.

You can use Data::Dumper to print out the data structure for debuggging:

    use Data::Dumper;
    warn Dumper $c;

warn() will put it in your error log, or you can print it to a file or to STDOUT to make it show up on your web page, but you'd want to make sure to print a header first (eg. print $cgi->header or print "Content-type: text/plain\r\n")

hope that helps,
nathan


>>> rustin <rustin@telstra.com> 06/18/03 05:56PM >>>
Hi,

i'm running swish.cgi just fine, but now have a need to support multiple
users who will be authenticated and have a cookie set. based on their
cookie, their view of indexes (and document sets) will be restricted.

I'd like to modify the existing cgi script to do this on the fly, and
have been trying to modify default_config, spcifically the values
allocated to swish_index and select_indexes labels.

i think my problem is more a perl issue as to how i embed if statements
(eg if $cookie then ... else ...) within the hash reference, but hope
someone can help. i'm open to other approaches if there are better ways
to tackle this.

thanks,

justin

----------------
Powered by telstra.com

 
Received on Thu Jun 19 17:41:24 2003