[Koha-bugs] [Bug 9866] OPAC advanced search error with Solr enabled

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu May 23 14:18:41 CEST 2013


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9866

--- Comment #4 from Hend <hend.eleraky at bibalex.org> ---
I tried to make a way round to fix this problem .Here are  the steps that i had
done . 

1- copy opac-search.tt to "search" directory  and name it  advsearch.tt.
2- Add advanced search part to search.pl [copy from opac-search.pl ]

Added the following part after  " my $itemtypes = GetItemTypes; " line

#----------------Advanced Search----------------------
# the index parameter is different for item-level itemtypes
my $itype_or_itemtype =
(C4::Context->preference("item-level_itypes"))?'itype':'itemtype';
my @advancedsearchesloop;
my $cnt;
my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") ||
"itemtypes";
my @advanced_search_types = split(/\|/, $advanced_search_types);

foreach my $advanced_srch_type (@advanced_search_types) {
   if ($advanced_srch_type eq 'itemtypes') {
   # itemtype is a special case, since it's not defined in authorized values
        my @itypesloop;
    foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp
$itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
        my %row =(  number=>$cnt++,
        ccl => "$itype_or_itemtype,phr",
                code => $thisitemtype,
                description => $itemtypes->{$thisitemtype}->{'description'},
                imageurl=> getitemtypeimagelocation( 'opac',
$itemtypes->{$thisitemtype}->{'imageurl'} ),
            );
        push @itypesloop, \%row;
    }
        my %search_code = (  advanced_search_type => $advanced_srch_type,
                             code_loop => \@itypesloop );
        push @advancedsearchesloop, \%search_code;
    } else {
    # covers all the other cases: non-itemtype authorized values
       my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, '',
'opac');
        my @authvalueloop;
    for my $thisitemtype (@$advsearchtypes) {
        my %row =(
                number=>$cnt++,
                ccl => $advanced_srch_type,
                code => $thisitemtype->{authorised_value},
                description => $thisitemtype->{'lib_opac'} ||
$thisitemtype->{'lib'},
                imageurl => getitemtypeimagelocation( 'opac',
$thisitemtype->{'imageurl'} ),
                );
        push @authvalueloop, \%row;
    }
        my %search_code = (  advanced_search_type => $advanced_srch_type,
                             code_loop => \@authvalueloop );
        push @advancedsearchesloop, \%search_code;
    }
}
$template->param(advancedsearchesloop => \@advancedsearchesloop);
# The following should only be loaded if we're bringing up the advanced search
template
if ( $template_type && $template_type eq 'advsearch' ) {
    # load the servers (used for searching -- to do federated searching, etc.)
    my $primary_servers_loop;# = displayPrimaryServers();
    $template->param(outer_servers_loop =>  $primary_servers_loop,);

    my $secondary_servers_loop;
    $template->param(outer_sup_servers_loop => $secondary_servers_loop,);

    # set the default sorting
    if (   C4::Context->preference('OPACdefaultSortField')
        && C4::Context->preference('OPACdefaultSortOrder') ) {
        my $default_sort_by =
            C4::Context->preference('OPACdefaultSortField') . '_'
          . C4::Context->preference('OPACdefaultSortOrder');
        $template->param( sort_by => $default_sort_by );
    }

    # determine what to display next to the search boxes (ie, boolean option
    # shouldn't appear on the first one, scan indexes should, adding a new
    # box should only appear on the last, etc.
    my @search_boxes_array;
    my $search_boxes_count = 3; # begin whith 3 boxes
    for (my $i=1;$i<=$search_boxes_count;$i++) {
        # if it's the first one, don't display boolean option, but show scan
indexes
        if ($i==1) {
            push @search_boxes_array,
                {
                scan_index => 1,
                };

        }
        # if it's the last one, show the 'add field' box
        elsif ($i==$search_boxes_count) {
            push @search_boxes_array,
                {
                boolean => 1,
                add_field => 1,
                };
        }
        else {
            push @search_boxes_array,
                {
                boolean => 1,
                };
        }

    }
    $template->param(uc(    C4::Context->preference("marcflavour")) => 1,   #
we already did this for UNIMARC
                            advsearch => 1,
                            search_boxes_loop => \@search_boxes_array);

    # use the global setting by default
    if ( C4::Context->preference("expandedSearchOption") == 1 ) {
        $template->param( expanded_options =>
C4::Context->preference("expandedSearchOption") );
    }
    # but let the user override it
    if (defined $cgi->param('expanded_options')) {
        if ( ($cgi->param('expanded_options') == 0) ||
($cgi->param('expanded_options') == 1 ) ) {
            $template->param( expanded_options =>
$cgi->param('expanded_options'));
        }
    }
}

#-----------------------------------------------------


Now i could use advanced search. 
Please could you review it and check if there's any part that i am missing.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list