Bugzilla – Attachment 11348 Details for
Bug 8571
Add search suggestions on the OPAC ("Did you mean?" feature)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add search suggestions to search results on the OPAC.
0001-Add-search-suggestions-to-search-results-on-the-OPAC.patch (text/plain), 4.56 KB, created by
Frédérick Capovilla
on 2012-08-03 18:59:11 UTC
(
hide
)
Description:
Add search suggestions to search results on the OPAC.
Filename:
MIME Type:
Creator:
Frédérick Capovilla
Created:
2012-08-03 18:59:11 UTC
Size:
4.56 KB
patch
obsolete
>From efe0b5c60d1041472be40de3a32e2c136658ab0f Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= <frederick.capovilla@libeo.com> >Date: Fri, 3 Aug 2012 14:39:02 -0400 >Subject: [PATCH] Add search suggestions to search results on the OPAC. > >The suggestions are based on the "see from" values in authority records. >--- > .../prog/en/modules/admin/preferences/opac.pref | 6 ++++ > .../prog/en/modules/opac-results-grouped.tt | 9 +++++ > .../opac-tmpl/prog/en/modules/opac-results.tt | 9 +++++ > opac/opac-search.pl | 32 ++++++++++++++++++++ > 4 files changed, 56 insertions(+), 0 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index eb74d81..de40b10 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -330,6 +330,12 @@ OPAC: > yes: Enable > no: Disable > - browsing and paging search results from the OPAC detail page. >+ - >+ - pref: OPACSearchSuggestions >+ choices: >+ yes: Show >+ no: "Don't show" >+ - 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. > > Policy: > - >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >index 99c31bd..8fedd76 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >@@ -98,6 +98,15 @@ function highlightOn() { > </ul> > [% END %] > >+[% IF ( suggestionsloop ) %] >+ <div class="suggestions"> >+ <span>Did you mean : </span> >+ [% FOREACH suggestionsloo IN suggestionsloop %] >+ <a href="/cgi-bin/koha/opac-search.pl?q=[% suggestionsloo.suggestionquery |url %]">[% suggestionsloo.suggestionterm %]</a> >+ [% END %] >+ </div> >+[% END %] >+ > [% IF ( query_error ) %] > <div class="dialog alert"> > <h4>Error:</h4> >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >index 9361419..5160561 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -260,6 +260,15 @@ $(document).ready(function(){ > </ul> > [% END %] > >+[% IF ( suggestionsloop ) %] >+ <div class="suggestions"> >+ <span>Did you mean : </span> >+ [% FOREACH suggestionsloo IN suggestionsloop %] >+ <a href="/cgi-bin/koha/opac-search.pl?q=[% suggestionsloo.suggestionquery |url %]">[% suggestionsloo.suggestionterm %]</a> >+ [% END %] >+ </div> >+[% END %] >+ > [% IF ( query_error ) %] > <div class="dialog alert"> > <h4>Error:</h4> >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 5f3ad86..546adcb 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -780,6 +780,38 @@ if ($query_desc || $limit_desc) { > $template->param(searchdesc => 1); > } > >+# III. LOOK FOR SEARCH SUGGESTIONS IN AUTHORITIES >+ >+if (C4::Context->preference('OPACSearchSuggestions')) { >+ # Search for authorities that could better represent the search query >+ my @suggestions; >+ >+ # Set the index of all operands for Match-heading-see-from search >+ my @indexes_match; >+ foreach(@operands){push(@indexes_match, 'Match-heading-see-from,ext');} >+ >+ # Build the query and do a simple search with it >+ ($error, $query) = buildQuery(\@operators,\@operands,\@indexes_match,0,0,0,$lang); >+ my ($error2, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] ); >+ >+ # Add the main Heading of each search result and add it to the suggestion list >+ foreach my $r (@$results) >+ { >+ my $record = MARC::Record->new_from_usmarc( $r ); >+ my @subfields = ($record->field('1..'))[0]->subfields(); >+ >+ # Fuse the subfields >+ my $suggestionterm = ''; >+ foreach(@subfields){$suggestionterm .= $_->[1] . ', ';} >+ $suggestionterm =~ s/,\s+$//; >+ >+ my $suggestion = {'suggestionterm' => $suggestionterm, 'suggestionquery' => $suggestionterm}; >+ push(@suggestions, $suggestion); >+ } >+ >+ $template->param( 'suggestionsloop' => \@suggestions ); >+} >+ > # VI. BUILD THE TEMPLATE > # Build drop-down list for 'Add To:' menu... > my ($totalref, $pubshelves, $barshelves)= >-- >1.7.2.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8571
:
11348
|
39498