Bug 13205: Last/first page options for result list paging
authorAleisha Amohia <aleishaamohia@hotmail.com>
Wed, 15 Feb 2017 02:42:10 +0000 (02:42 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 9 Oct 2017 19:15:48 +0000 (16:15 -0300)
This patch adds first and last page buttons to the pagination at the
bottom of a page of catalog search results.

To test:
1) Apply patch
2) Do a number of searches
3) For each search, ensure that the first and last page buttons work as
expected

Sponsored-by: Catalyst IT

Followed test plan, works as expected.
Signed-off-by: Marc VĂ©ron <veron@veron.ch>

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

catalogue/search.pl
koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc

index 7a8cf12..7b8e5e2 100755 (executable)
@@ -617,6 +617,7 @@ for (my $i=0;$i<@servers;$i++) {
             my @page_numbers;
             # total number of pages there will be
             my $pages = ceil($hits / $results_per_page);
+            my $last_page = ($pages * $results_per_page) - $results_per_page;
             # default page number
             my $current_page_number = 1;
             $current_page_number = ($offset / $results_per_page + 1) if $offset;
@@ -667,6 +668,7 @@ for (my $i=0;$i<@servers;$i++) {
             }
             # FIXME: no previous_page_offset when pages < 2
             $template->param(   PAGE_NUMBERS => \@page_numbers,
+                                last_page => $last_page,
                                 previous_page_offset => $previous_page_offset) unless $pages < 2;
             $template->param(   next_page_offset => $next_page_offset) unless $pages eq $current_page_number;
         }
index bf277c0..d593cdf 100644 (file)
@@ -1,7 +1,14 @@
 [% IF ( PAGE_NUMBERS ) %]<nav><ul class="pagination">
+    <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">First</a></li>
     <!-- Row of numbers corresponding to search result pages -->
-        [% IF ( previous_page_offset.defined ) %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% previous_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">&lt;&lt; Previous</a></li>[% END %]
-    [% FOREACH PAGE_NUMBER IN PAGE_NUMBERS %][% IF ( PAGE_NUMBER.highlight ) %]<li class="active"><span>[% PAGE_NUMBER.pg %]</span></li>[% ELSE %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">[% PAGE_NUMBER.pg %]</a></li>[% END %]
+    [% IF ( previous_page_offset.defined ) %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% previous_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">&lt;&lt; Previous</a></li>[% END %]
+    [% FOREACH PAGE_NUMBER IN PAGE_NUMBERS %]
+        [% IF ( PAGE_NUMBER.highlight ) %]
+            <li class="active"><span>[% PAGE_NUMBER.pg %]</span></li>
+        [% ELSE %]
+            <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">[% PAGE_NUMBER.pg %]</a></li>
+        [% END %]
     [% END %]
-        [% IF ( next_page_offset ) %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% next_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">Next &gt;&gt;</a></li>[% END %]
+    [% IF ( next_page_offset ) %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% next_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">Next &gt;&gt;</a></li>[% END %]
+    <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% last_page %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">Last</a></li>
 </ul></nav>[% END %]