Skip to main content.
home | support | download

Back to List Archive

Re: get_limit_select on two metas

From: Cas Tuyn <cas.tuyn(at)not-real.gmail.com>
Date: Wed Dec 27 2006 - 15:21:40 GMT
Hi,

> > It's what generates the HTML.  You will have to search through
> > swish.cgi and find how it makes use of "sbm" and duplicate that as
> > well

In swish.cgi I have defined the sbm and sbme parameters in the query:

(in sub set_navigation)
    for my $p ( qw/si sbm sbme/ ) {

(in sub build_query)
    ## Look for a "limit" metaname -- perhaps used with ExtractPath
    # Here we don't worry about user supplied data

    my $limits = $self->config('select_by_meta');
    my @limits = $q->param('sbm');  # Select By Metaname


    # Note that this could be messed up by ending the query in a NOT or OR
    # Should look into doing:
    # $query = "( $query ) AND " . $limits->{metaname} . '=(' . join(
' OR ', @limits ) . ')';

    if ( @limits && ref $limits eq 'HASH' && $limits->{metaname} ) {
        $query .= ' and ' . $limits->{metaname} . '=(' . join( ' or ',
@limits ) . ')';
    }


    ## Look for a "second limit" metaname -- copied from above (Cas 20061227)
    # Here we don't worry about user supplied data

    my $seclimits = $self->config('select_by_meta_ext');
    my @seclimits = $q->param('sbme');  # Select By Metaname

    if ( @seclimits && ref $seclimits eq 'HASH' && $seclimits->{metaname} ) {
        $query .= ' and ' . $seclimits->{metaname} . '=(' . join( ' or
', @seclimits ) . ')';
    }


In TemplateToolkit.pm and in TemplateDefault.pm I have (exactly equal):

sub get_limit_select_sector {
    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 );
}

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


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

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

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

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


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


Yet nothing happens when i try to limit my search results for an
extension, and it works OK when I want to limit my search results for
a 'sector'.

Is there anything else that needs copying?

Regards,

Cas
Received on Wed Dec 27 07:22:02 2006