View | Details | Raw Unified | Return to bug 8571
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 468-473 OPAC: Link Here
468
                  yes: Display
468
                  yes: Display
469
                  no: Don't display
469
                  no: Don't display
470
            - the acquisition details on OPAC detail pages.
470
            - the acquisition details on OPAC detail pages.
471
        -
472
            - pref: OPACSearchSuggestions
473
              choices:
474
                  yes: Show
475
                  no: "Don't show"
476
            - search suggestions in the OPAC's search results page. Suggestions are found by searching for the search terms in the "see-from" of authority records.
477
471
    Policy:
478
    Policy:
472
        -
479
        -
473
            - pref: singleBranchMode
480
            - pref: singleBranchMode
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt (+9 lines)
Lines 27-32 href="/cgi-bin/koha/opac-rss.pl?[% query_cgi %][% limit_cgi |html %]" /> Link Here
27
            </li>
27
            </li>
28
        </ul>
28
        </ul>
29
29
30
        [% IF ( suggestionsloop ) %]
31
            <div class="suggestions">
32
                <span>Did you mean : </span>
33
                [% FOREACH suggestionsloo IN suggestionsloop %]
34
                    <a href="/cgi-bin/koha/opac-search.pl?q=[% suggestionsloo.suggestionquery |url %]">[% suggestionsloo.suggestionterm %]</a>&nbsp;&nbsp;
35
                [% END %]
36
            </div>
37
        [% END %]
38
30
        [% IF ( query_error ) %]
39
        [% IF ( query_error ) %]
31
            <div class="container-fluid">
40
            <div class="container-fluid">
32
                <div class="row-fluid">
41
                <div class="row-fluid">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt (+8 lines)
Lines 114-119 Link Here
114
                            </div>
114
                            </div>
115
                        [% END %]
115
                        [% END %]
116
                    [% END %]
116
                    [% END %]
117
                    [% IF ( suggestionsloop ) %]
118
                        <div class="suggestions">
119
                            <span>Did you mean : </span>
120
                            [% FOREACH suggestionsloo IN suggestionsloop %]
121
                                <a href="/cgi-bin/koha/opac-search.pl?q=[% suggestionsloo.suggestionquery |url %]">[% suggestionsloo.suggestionterm %]</a>&nbsp;&nbsp;
122
                            [% END %]
123
                        </div>
124
                    [% END %]
117
                    [% IF ( query_error ) %]
125
                    [% IF ( query_error ) %]
118
                        <div class="dialog alert">
126
                        <div class="dialog alert">
119
                            <h4>Error:</h4>
127
                            <h4>Error:</h4>
(-)a/opac/opac-search.pl (-1 / +32 lines)
Lines 918-923 if ($query_desc || $limit_desc) { Link Here
918
    $template->param(searchdesc => 1);
918
    $template->param(searchdesc => 1);
919
}
919
}
920
920
921
# III. LOOK FOR SEARCH SUGGESTIONS IN AUTHORITIES
922
923
if (C4::Context->preference('OPACSearchSuggestions')) {
924
    # Search for authorities that could better represent the search query
925
    my @suggestions;
926
 
927
    # Set the index of all operands for Match-heading-see-from search
928
    my @indexes_match;
929
    foreach(@operands){push(@indexes_match, 'Match-heading-see-from,ext');}
930
 
931
    # Build the query and do a simple search with it
932
    ($error, $query) = buildQuery(\@operators,\@operands,\@indexes_match,0,0,0,$lang);
933
    my ($error2, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
934
 
935
    # Add the main Heading of each search result and add it to the suggestion list
936
    foreach my $r (@$results)
937
    {
938
        my $record = MARC::Record->new_from_usmarc( $r );
939
        my @subfields = ($record->field('1..'))[0]->subfields();   
940
 
941
        # Fuse the subfields
942
        my $suggestionterm = '';
943
        foreach(@subfields){$suggestionterm .= $_->[1] . ', ';}
944
        $suggestionterm =~ s/,\s+$//;
945
 
946
        my $suggestion = {'suggestionterm' => $suggestionterm, 'suggestionquery' => $suggestionterm};
947
        push(@suggestions, $suggestion);
948
    }
949
 
950
    $template->param( 'suggestionsloop' => \@suggestions );
951
}
952
921
# VI. BUILD THE TEMPLATE
953
# VI. BUILD THE TEMPLATE
922
# Build drop-down list for 'Add To:' menu...
954
# Build drop-down list for 'Add To:' menu...
923
my ($totalref, $pubshelves, $barshelves)=
955
my ($totalref, $pubshelves, $barshelves)=
924
- 

Return to bug 8571