Fixed pagination when no pages should be shown
This commit is contained in:
parent
b5581c5822
commit
4d260b6fe5
1 changed files with 42 additions and 40 deletions
|
@ -31,6 +31,18 @@ if (!function_exists('pageUrl'))
|
|||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
$pagesVisible = [];
|
||||
$pagesVisible []= 1;
|
||||
$pagesVisible []= $this->context->transport->pageCount;
|
||||
$delta = 3;
|
||||
$pagesVisible = array_merge($pagesVisible, range($this->context->transport->page - $delta, $this->context->transport->page + $delta));
|
||||
$pagesVisible = array_filter($pagesVisible, function($x) { return $x >= 1 and $x <= $this->context->transport->pageCount; });
|
||||
$pagesVisible = array_unique($pagesVisible);
|
||||
sort($pagesVisible, SORT_NUMERIC);
|
||||
?>
|
||||
|
||||
<?php if (!empty($pagesVisible)): ?>
|
||||
<nav class="paginator-wrapper">
|
||||
<ul class="paginator">
|
||||
<?php if ($this->context->transport->page > 1): ?>
|
||||
|
@ -43,17 +55,6 @@ if (!function_exists('pageUrl'))
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
$pagesVisible = [];
|
||||
$pagesVisible []= 1;
|
||||
$pagesVisible []= $this->context->transport->pageCount;
|
||||
$delta = 3;
|
||||
$pagesVisible = array_merge($pagesVisible, range($this->context->transport->page - $delta, $this->context->transport->page + $delta));
|
||||
$pagesVisible = array_filter($pagesVisible, function($x) { return $x >= 1 and $x <= $this->context->transport->pageCount; });
|
||||
$pagesVisible = array_unique($pagesVisible);
|
||||
sort($pagesVisible, SORT_NUMERIC);
|
||||
?>
|
||||
|
||||
<?php foreach ($pagesVisible as $page): ?>
|
||||
<?php if ($page == $this->context->transport->page): ?>
|
||||
<li class="active">
|
||||
|
@ -77,3 +78,4 @@ if (!function_exists('pageUrl'))
|
|||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<?php endif ?>
|
||||
|
|
Reference in a new issue