Bug 15839: [QA Follow-up] Paging on opac-showreviews
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 29 Jul 2016 07:27:58 +0000 (09:27 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 9 Sep 2016 10:31:05 +0000 (10:31 +0000)
Paging is kind of messy here. This patch at least improves somewhat.
The page number should be rounded.
The results per page should be passed to the template too.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested a number of reviews and played with count parameter in URL.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-showreviews.tt
opac/opac-showreviews.pl

index 464aa21..507c118 100644 (file)
                             <div class="pages">
                                 <!-- Row of numbers corresponding to showreviews result pages -->
                                 [% IF ( previous_page_offset ) %]
-                                    <a class="nav" href="/cgi-bin/koha/opac-showreviews.pl?offset=[% previous_page_offset %]">&lt;&lt; Previous</a>
+                                    <a class="nav" href="/cgi-bin/koha/opac-showreviews.pl?offset=[% previous_page_offset %]&count=[% results_per_page %]">&lt;&lt; Previous</a>
                                 [% ELSE %]
                                     [% IF ( previous_page_first ) %]
-                                        <a class="nav" href="/cgi-bin/koha/opac-showreviews.pl?offset=0">&lt;&lt; Previous</a>
+                                        <a class="nav" href="/cgi-bin/koha/opac-showreviews.pl?offset=0&count=[% results_per_page %]">&lt;&lt; Previous</a>
                                     [% END %]
                                 [% END %]
                                 [% FOREACH PAGE_NUMBER IN PAGE_NUMBERS %]
                                     [% IF ( PAGE_NUMBER.highlight ) %]
                                         <span class="currentPage">[% PAGE_NUMBER.pg %]</span>
                                     [% ELSE %]
-                                        <a class="nav" href="/cgi-bin/koha/opac-showreviews.pl?offset=[% PAGE_NUMBER.offset %]">[% PAGE_NUMBER.pg %]</a>
+                                        <a class="nav" href="/cgi-bin/koha/opac-showreviews.pl?offset=[% PAGE_NUMBER.offset %]&count=[% results_per_page %]">[% PAGE_NUMBER.pg %]</a>
                                     [% END %]
                                 [% END %]
                                 [% IF ( next_page_offset ) %]
-                                    <a class="nav" href="/cgi-bin/koha/opac-showreviews.pl?offset=[% next_page_offset %]">Next &gt;&gt;</a>
+                                    <a class="nav" href="/cgi-bin/koha/opac-showreviews.pl?offset=[% next_page_offset %]&count=[% results_per_page %]">Next &gt;&gt;</a>
                                 [% END %]
                             </div>
                         [% END # / IF PAGE_NUMBERS %]
index 995ad70..839a536 100755 (executable)
@@ -30,7 +30,7 @@ use C4::Biblio;
 use C4::Members qw/GetMemberDetails/;
 use Koha::DateUtils;
 use Koha::Reviews;
-use POSIX qw(ceil strftime);
+use POSIX qw(ceil floor strftime);
 
 my $template_name;
 my $query = new CGI;
@@ -38,7 +38,7 @@ my $format = $query->param("format") || '';
 my $count = C4::Context->preference('OPACnumSearchResults') || 20;
 my $results_per_page = $query->param('count') || $count;
 my $offset = $query->param('offset') || 0;
-my $page = $offset / $results_per_page + 1;
+my $page = floor( $offset / $results_per_page ) + 1;
 
 if ($format eq "rss") {
     $template_name = "opac-showreviews-rss.tt";
@@ -180,6 +180,7 @@ $template->param(next_page_offset => $next_page_offset) unless $pages eq $curren
 
 $template->param(
     reviews => $reviews,
+    results_per_page => $results_per_page,
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;