Bug 15839: [QA Follow-up] Paging on opac-showreviews

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>
This commit is contained in:
Marcel de Rooy 2016-07-29 09:27:58 +02:00 committed by Kyle M Hall
parent ac59bed98a
commit b5c3b1c974
2 changed files with 7 additions and 6 deletions

View file

@ -154,21 +154,21 @@
<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 %]

View file

@ -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;