Skip to content

Commit

Permalink
Merge pull request #23 from smahelos/fix-next-and-last-links
Browse files Browse the repository at this point in the history
FIX: Pagination Next and Last links
  • Loading branch information
MrRoco authored Mar 15, 2019
2 parents 483d527 + a430c90 commit 0eca8f3
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function getPagination($searchString = '', $perPage = 10, $separator = '
$pageArray['offset'] = $i * $perPage;

$currentOffset = intval($this->modx->getOption($searchOffset,$_GET,0));
if ($pageLimit > 0 && $i + 1 === 1 && $pageArray['offset'] !== $currentOffset && !empty($pageFirstTpl)) {
if (!empty($pageFirstTpl) && $pageLimit > 0 && $i + 1 === 1 && (int)$pageArray['offset'] !== $currentOffset) {
$parameters = $this->modx->request->getParameters();
$parameters = array_merge(
$parameters,
Expand Down Expand Up @@ -260,7 +260,7 @@ public function getPagination($searchString = '', $perPage = 10, $separator = '
$pagination .= $this->getChunk($pagePrevTpl,$pageArray);
}
}
if (empty($pageLimit) || ($pageArray['offset'] >= $currentOffset - ($pageLimit * $perPage) && $pageArray['offset'] <= $currentOffset + ($pageLimit * $perPage))) {
if (empty($pageLimit) || ((int)$pageArray['offset'] >= $currentOffset - ($pageLimit * $perPage) && (int)$pageArray['offset'] <= $currentOffset + ($pageLimit * $perPage))) {
if ($currentOffset === $pageArray['offset']) {
$pageArray['text'] = $i + 1;
$pageArray['link'] = $i + 1;
Expand All @@ -281,7 +281,7 @@ public function getPagination($searchString = '', $perPage = 10, $separator = '
$pagination .= $this->getChunk($pageTpl,$pageArray);
}
}
if ($pageLimit > 0 && $i + 1 === $pageLinkCount && $pageArray['offset'] !== $currentOffset && !empty($pageLastTpl)) {
if (!empty($pageLastTpl) && $pageLimit > 0 && $i + 1 === (int)$pageLinkCount && (int)$pageArray['offset'] !== $currentOffset) {
if (!empty($pageNextTpl) && ($currentOffset + $perPage) <= $total) {
$parameters = $this->modx->request->getParameters();
$parameters = array_merge(
Expand Down

0 comments on commit 0eca8f3

Please sign in to comment.