Skip to main content.
home | support | download

Back to List Archive

get_limit_select on two metas

From: Cas Tuyn <cas.tuyn(at)not-real.gmail.com>
Date: Fri Dec 22 2006 - 16:11:53 GMT
Hi,

I run Swish-2.4.3 on Solaris, starting with a default swish.cgi,
TemplateDefault.pm and TemplateToolkit.pm.

It runs file already using commands inside the search string, but I
want to make it userfriendlier by also offering an advanced search. I
want to use not one, but two select-by-meta items (part of the path,
and extension of the file). The part of the path I did using the
default provided "select_by_meta" using the meta name "sector" which
works flawlessly.

To add a second selection, I added "select_by_meta_ext" using the meta
name "ext" (extension, which allows the user to limit his search to
html, pdf, doc, ppt, etc.) to TemplateDefault.pm by copying the
working "select_by_meta" as "select_by_meta_ext" and changing the meta
name. It displays fine, even gets shown in the URL parameters, but
nothing happens.

I saw that TemplateToolkit.pm is the file that does the processing,
and in there I found "get_limit_select" acting on the "sbm" variable.
What do I need to change to take the second meta field "ext" also into
account? Below the still-standard code:

sub get_limit_select {
    my ( $results ) = @_;
    my $q = $results->CGI;

    my $limit = $results->config('select_by_meta');
    return '' unless ref $limit eq 'HASH';

    my $method = $limit->{method} || 'checkbox_group';

    my @options = (
        -name   => 'sbm',
        -values => $limit->{values},
        -labels => $limit->{labels} || {},
    );

    push @options, ( -columns=> $limit->{columns} ) if $limit->{columns};

    return join "\n",
        '<br>',
        ( $limit->{description} || 'Select: '),
        $q->$method( @options );
}

If someone has done this before, or has tips, I would be grateful,

Kind regards,

Cas
Received on Fri Dec 22 08:12:04 2006