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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+6 lines)
Lines 330-335 OPAC: Link Here
330
                  yes: Enable
330
                  yes: Enable
331
                  no: Disable
331
                  no: Disable
332
            - browsing and paging search results from the OPAC detail page.
332
            - browsing and paging search results from the OPAC detail page.
333
        -
334
            - pref: OPACSearchSuggestions
335
              choices:
336
                  yes: Show
337
                  no: "Don't show"
338
            - 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.
333
339
334
    Policy:
340
    Policy:
335
        -
341
        -
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt (+9 lines)
Lines 98-103 function highlightOn() { Link Here
98
    </ul>
98
    </ul>
99
[% END %]
99
[% END %]
100
100
101
[% IF ( suggestionsloop ) %]
102
    <div class="suggestions">
103
        <span>Did you mean : </span>
104
        [% FOREACH suggestionsloo IN suggestionsloop %]
105
            <a href="/cgi-bin/koha/opac-search.pl?q=[% suggestionsloo.suggestionquery |url %]">[% suggestionsloo.suggestionterm %]</a>&nbsp;&nbsp;
106
        [% END %]
107
    </div>
108
[% END %]
109
101
[% IF ( query_error ) %]
110
[% IF ( query_error ) %]
102
<div class="dialog alert">
111
<div class="dialog alert">
103
	<h4>Error:</h4>
112
	<h4>Error:</h4>
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt (+9 lines)
Lines 260-265 $(document).ready(function(){ Link Here
260
    </ul>
260
    </ul>
261
[% END %]
261
[% END %]
262
262
263
[% IF ( suggestionsloop ) %]
264
    <div class="suggestions">
265
        <span>Did you mean : </span>
266
        [% FOREACH suggestionsloo IN suggestionsloop %]
267
            <a href="/cgi-bin/koha/opac-search.pl?q=[% suggestionsloo.suggestionquery |url %]">[% suggestionsloo.suggestionterm %]</a>&nbsp;&nbsp;
268
        [% END %]
269
    </div>
270
[% END %]
271
263
[% IF ( query_error ) %]
272
[% IF ( query_error ) %]
264
<div class="dialog alert">
273
<div class="dialog alert">
265
    <h4>Error:</h4>
274
    <h4>Error:</h4>
(-)a/opac/opac-search.pl (-1 / +32 lines)
Lines 780-785 if ($query_desc || $limit_desc) { Link Here
780
    $template->param(searchdesc => 1);
780
    $template->param(searchdesc => 1);
781
}
781
}
782
782
783
# III. LOOK FOR SEARCH SUGGESTIONS IN AUTHORITIES
784
785
if (C4::Context->preference('OPACSearchSuggestions')) {
786
    # Search for authorities that could better represent the search query
787
    my @suggestions;
788
789
    # Set the index of all operands for Match-heading-see-from search
790
    my @indexes_match;
791
    foreach(@operands){push(@indexes_match, 'Match-heading-see-from,ext');}
792
793
    # Build the query and do a simple search with it
794
    ($error, $query) = buildQuery(\@operators,\@operands,\@indexes_match,0,0,0,$lang);
795
    my ($error2, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
796
797
    # Add the main Heading of each search result and add it to the suggestion list
798
    foreach my $r (@$results)
799
    {
800
        my $record = MARC::Record->new_from_usmarc( $r );
801
        my @subfields = ($record->field('1..'))[0]->subfields();   
802
803
        # Fuse the subfields
804
        my $suggestionterm = '';
805
        foreach(@subfields){$suggestionterm .= $_->[1] . ', ';}
806
        $suggestionterm =~ s/,\s+$//;
807
808
        my $suggestion = {'suggestionterm' => $suggestionterm, 'suggestionquery' => $suggestionterm};
809
        push(@suggestions, $suggestion);
810
    }
811
812
    $template->param( 'suggestionsloop' => \@suggestions );
813
}
814
783
# VI. BUILD THE TEMPLATE
815
# VI. BUILD THE TEMPLATE
784
# Build drop-down list for 'Add To:' menu...
816
# Build drop-down list for 'Add To:' menu...
785
my ($totalref, $pubshelves, $barshelves)=
817
my ($totalref, $pubshelves, $barshelves)=
786
- 

Return to bug 8571