Bug 14715: Results per page dropdown for catalogue search
authorAleisha Amohia <aleishaamohia@hotmail.com>
Tue, 5 Nov 2019 02:53:26 +0000 (02:53 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 26 Mar 2020 12:03:42 +0000 (12:03 +0000)
This patch utilises an unused search facet to handle results shown per
page.

Sponsored-by: Region Halland
Signed-off-by: Gabriel DeCarufel <gabriel@inlibro.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

installer/data/mysql/atomicupdate/bug_14715-add_resultsperpagedropdown_sysprefs.perl [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt

diff --git a/installer/data/mysql/atomicupdate/bug_14715-add_resultsperpagedropdown_sysprefs.perl b/installer/data/mysql/atomicupdate/bug_14715-add_resultsperpagedropdown_sysprefs.perl
new file mode 100644 (file)
index 0000000..c107cb6
--- /dev/null
@@ -0,0 +1,11 @@
+$DBversion = 'XXX';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES
+        ('OPACnumSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in OPAC search results','YesNo'),
+        ('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff client search results','YesNo')
+    });
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 14715 - Add sysprefs numSearchResultsDropdown and OPACnumSearchResultsDropdown)\n";
+}
index 3992c62..01ec32d 100644 (file)
@@ -344,6 +344,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('numReturnedItemsToShow','20',NULL,'Number of returned items to show on the check-in page','Integer'),
 ('NumSavedReports', '20', NULL, 'By default, show this number of saved reports.', 'Integer'),
 ('numSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'),
+('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff client search results','YesNo'),
 ('numSearchRSSResults','50',NULL,'Specify the maximum number of results to display on a RSS page of results','Integer'),
 ('OAI-PMH','0',NULL,'if ON, OAI-PMH server is enabled','YesNo'),
 ('OAI-PMH:archiveID','KOHA-OAI-TEST',NULL,'OAI-PMH archive identification','Free'),
@@ -414,6 +415,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('OPACNoResultsFound','','70|10','Display this HTML when no results are found for a search in the OPAC','Textarea'),
 ('OPACNumbersPreferPhrase','0',NULL,'Control the use of phr operator in callnumber and standard number OPAC searches','YesNo'),
 ('OPACnumSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'),
+('OPACnumSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in OPAC search results','YesNo'),
 ('OpacPasswordChange','1',NULL,'If ON, enables patron-initiated password change in OPAC (disable it when using LDAP auth)','YesNo'),
 ('OPACPatronDetails','1','','If OFF the patron details tab in the OPAC is disabled.','YesNo'),
 ('OPACpatronimages','0',NULL,'Enable patron images in the OPAC','YesNo'),
index 4fb9a6b..03cf92d 100644 (file)
@@ -1,19 +1,19 @@
 [% IF ( PAGE_NUMBERS ) %]<nav><ul class="pagination">
  [% IF hits_to_paginate < total %]<h6>[% hits_to_paginate | html %] of [% total | html %] results loaded, refine your search to view other records</h6>[% END %]
     [% IF ( previous_page_offset.defined ) %]
-        <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
+        <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
         <!-- Row of numbers corresponding to search result pages -->
-        <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% previous_page_offset | html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]"><i class="fa fa-fw fa-angle-left"></i> Previous</a></li>
+        <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% previous_page_offset | html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]"><i class="fa fa-fw fa-angle-left"></i> Previous</a></li>
     [% END %]
     [% FOREACH PAGE_NUMBER IN PAGE_NUMBERS %]
         [% IF ( PAGE_NUMBER.highlight ) %]
             <li class="active"><span>[% PAGE_NUMBER.pg | html %]</span></li>
         [% ELSE %]
-            <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% PAGE_NUMBER.offset | html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">[% PAGE_NUMBER.pg | html %]</a></li>
+            <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% PAGE_NUMBER.offset | html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]">[% PAGE_NUMBER.pg | html %]</a></li>
         [% END %]
     [% END %]
     [% IF ( next_page_offset ) %]
-        <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% next_page_offset | html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">Next <i class="fa fa-fw fa-angle-right"></i></a></li>
-        <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% last_page_offset | html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">Last <i class="fa fa-fw fa-angle-double-right"></i></a></li>
+        <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% next_page_offset | html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]">Next <i class="fa fa-fw fa-angle-right"></i></a></li>
+        <li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% last_page_offset | html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]">Last <i class="fa fa-fw fa-angle-double-right"></i></a></li>
     [% END %]
 </ul></nav>[% END %]
index 9f2711a..adcb142 100644 (file)
@@ -133,6 +133,24 @@ Searching:
             - 'the operator "phr" in the callnumber and standard number staff client searches'
     Results Display:
         -
+            - pref: numSearchResultsDropdown
+              type: boolean
+              default: no
+              choices:
+                  yes: Show
+                  no: "Don't show"
+            - results per page dropdown on staff client search results.
+            - "Note: This does not work if ElasticSearch is activated."
+        -
+            - pref: OPACnumSearchResultsDropdown
+              type: boolean
+              default: no
+              choices:
+                  yes: Show
+                  no: "Don't show"
+            - results per page dropdown on OPAC search results.
+            - "Note: This does not work if ElasticSearch is activated."
+        -
             - By default, sort search results in the staff client by
             - pref: defaultSortField
               default: relevance
index 4b66e8e..b694d8e 100644 (file)
                                     [% END %]
                                 </ul>
                             </div> <!-- /.btn-group -->
+
+                            [% IF Koha.Preference('numSearchResultsDropdown') && Koha.Preference('SearchEngine') == "Zebra" %]
+                                <div class="btn-group">
+                                    <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                                        Results per page: [% results_per_page %] <span class="caret"></span>
+                                    </button>
+                                    <ul class="dropdown-menu">
+                                        [% IF Koha.Preference('numSearchResults') %]
+                                            <li><a href="#" id="resultsperpage-default">
+                                                [% IF results_per_page == Koha.Preference('numSearchResults') %]
+                                                    <i class="fa fa-check"></i>
+                                                [% END %] Library default: [% Koha.Preference('numSearchResults') %]
+                                            </a></li>
+                                        [% END %]
+                                        <li><a href="/cgi-bin/koha/catalogue/search.pl?count=20[% PROCESS sort_search_query %]">[% IF results_per_page == '20' %]<i class="fa fa-check"></i>[% END %] 20</a></li>
+                                        <li><a href="/cgi-bin/koha/catalogue/search.pl?count=40[% PROCESS sort_search_query %]" id="resultsperpage-40">[% IF results_per_page == '40' %]<i class="fa fa-check"></i>[% END %] 40</a></li>
+                                        <li><a href="/cgi-bin/koha/catalogue/search.pl?count=60[% PROCESS sort_search_query %]" id="resultsperpage-60">[% IF results_per_page == '60' %]<i class="fa fa-check"></i>[% END %] 60</a></li>
+                                        <li><a href="/cgi-bin/koha/catalogue/search.pl?count=80[% PROCESS sort_search_query %]" id="resultsperpage-80">[% IF results_per_page == '80' %]<i class="fa fa-check"></i>[% END %] 80</a></li>
+                                        <li><a href="/cgi-bin/koha/catalogue/search.pl?count=100[% PROCESS sort_search_query %]" id="resultsperpage-100">[% IF results_per_page == '100' %]<i class="fa fa-check"></i>[% END %] 100</a></li>
+                                    </ul>
+                                </div> <!-- /.btn-group -->
+                            [% END %]
+
                         </div> <!-- /#selection_ops -->
                     </div> <!-- /#searchheader -->
 
index 3633b0c..af10556 100644 (file)
@@ -3,19 +3,19 @@
      [% IF hits_to_paginate < total %]<h6>[% hits_to_paginate | html %] of [% total | html %] results loaded, refine your search to view other records</h6>[% END %]
         <ul>
             [% IF ( previous_page_offset.defined ) %]
-                <li class="page-first"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %]"><i class="fa fa-fw fa-angle-double-left"></i>  First</a></li>
-                <li class="page-prev"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% previous_page_offset | uri %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %]"> <i class="fa fa-fw fa-angle-left"></i>  Previous</a></li>
+                <li class="page-first"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]"><i class="fa fa-fw fa-angle-double-left"></i>  First</a></li>
+                <li class="page-prev"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% previous_page_offset | uri %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]"> <i class="fa fa-fw fa-angle-left"></i>  Previous</a></li>
             [% END %]
             [% FOREACH PAGE_NUMBER IN PAGE_NUMBERS %]
                 [% IF ( PAGE_NUMBER.highlight ) %]
                     <li class="active"><a clas="page-num current" href="#">[% PAGE_NUMBER.pg | html %]</a></li>
                 [% ELSE %]
-                    <li class="page-num"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% PAGE_NUMBER.offset | uri %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %]">[% PAGE_NUMBER.pg | html %]</a></li>
+                    <li class="page-num"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% PAGE_NUMBER.offset | uri %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]">[% PAGE_NUMBER.pg | html %]</a></li>
                 [% END %]
             [% END %]
             [% IF ( next_page_offset ) %]
-                <li class="page-next"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% next_page_offset | uri %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %]">Next <i class="fa fa-fw fa-angle-double-right"></i></a></li>
-                <li class="page-last"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% last_page_offset | uri %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %]">Last <i class="fa fa-fw fa-angle-double-right"></i></a></li>
+                <li class="page-next"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% next_page_offset | uri %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]">Next <i class="fa fa-fw fa-angle-double-right"></i></a></li>
+                <li class="page-last"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;offset=[% last_page_offset | uri %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %][% IF results_per_page %]&amp;count=[% results_per_page %][% END %]">Last <i class="fa fa-fw fa-angle-double-right"></i></a></li>
             [% END %]
         </ul>
     </div>
index 86baa9f..acd21db 100644 (file)
                                         [% UNLESS tag %]
                                             <div class="sort_by pull-right">
                                                 <select id="sort_by" class="resort" name="sort_by"> [% INCLUDE 'resort_form.inc' %] </select>
+
+                                                [% IF Koha.Preference('OPACnumSearchResultsDropdown') && Koha.Preference('SearchEngine') == "Zebra" %]
+                                                    <label for="results_per_page">Results per page: </label>
+                                                    <select id="results_per_page" name="count">
+                                                        [% IF Koha.Preference('OPACnumSearchResults') %]
+                                                            [% IF results_per_page == Koha.Preference('OPACnumSearchResults') %]
+                                                                <option value="[% Koha.Preference('OPACnumSearchResults') %]" selected="selected">Library default: [% Koha.Preference('OPACnumSearchResults') %]</option>
+                                                            [% ELSE %]
+                                                                <option value="[% Koha.Preference('OPACnumSearchResults') %]">Library default: [% Koha.Preference('OPACnumSearchResults') %]</option>
+                                                            [% END %]
+                                                        [% END %]
+                                                        [% IF results_per_page == '20' %]<option value="20" selected="selected">20</option>[% ELSE %]<option value="20">20</option>[% END %]
+                                                        [% IF results_per_page == '40' %]<option value="40" selected="selected">40</option>[% ELSE %]<option value="40">40</option>[% END %]
+                                                        [% IF results_per_page == '60' %]<option value="60" selected="selected">60</option>[% ELSE %]<option value="60">60</option>[% END %]
+                                                        [% IF results_per_page == '80' %]<option value="80" selected="selected">80</option>[% ELSE %]<option value="80">80</option>[% END %]
+                                                        [% IF results_per_page == '100' %]<option value="100" selected="selected">100</option>[% ELSE %]<option value="100">100</option>[% END %]
+                                                    </select>
+                                                [% END %]
+
                                                 <input type="submit" class="btn btn-sm clearfix" id="sortsubmit" value="Go" />
                                             </div>
                                         [% END %]
+                                        </div>
                                     </div> <!-- / #toolbar -->
 
                                     <div id="selections-toolbar" class="toolbar noprint">
@@ -758,6 +778,11 @@ $(document).ready(function(){
     $('.resort').change(function() {
         $('#bookbag_form').submit();
     });
+
+    $('#results_per_page').change(function() {
+        $('#bookbag_form').submit();
+    });
+
     $("span.clearall").html("<a id=\"CheckNone\" href=\"#\">"+_("Clear all")+"<\/a>");
     $("span.checkall").html("<a id=\"CheckAll\" href=\"#\">"+_("Select all")+"<\/a>");