Skip to main content.
home | support | download

Back to List Archive

Re: Sort by date in swish.cgi ...?

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Sat Jan 17 2004 - 14:00:22 GMT
On Fri, Jan 16, 2004 at 09:34:10PM -0800, Jordan Hayes wrote:
> [ A long time ago, I asked about this; Bill gave a good answer that I
> filed away until I recently upgraded my indexes ... ]
> 
> > Use:
> >
> >  PropertyNamesDate realdate
> 
> Ok, this seems to work great, although I'd rather have it reverse the
> sort by default.  Is there an easy way to do this in swish.cgi?

Not without getting your hands a little dirty.  Edit the 
set_sort_order() function in swish.cgi.  Here's were it sets the sort 
direction

    my $direction = $sortby eq 'swishrank'
        ? $q->param('reverse') ? 'asc' : 'desc'
        : $q->param('reverse') ? 'desc' : 'asc';

You might do something like

    my $direction = $sortby eq 'swishrank' || $sortby =~ /date/
        ? $q->param('reverse') ? 'asc' : 'desc'
        : $q->param('reverse') ? 'desc' : 'asc';


-- 
Bill Moseley
moseley@hank.org
Received on Sat Jan 17 14:01:04 2004