Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,16 @@ public function setPage($page)
*/
public function getPage()
{
// the page was previously set
if ($this->page) {
return $this->page;
// the page wasn't previously set
if (!$this->page) {
// get the current page from the URI
if (preg_match($this->buildPattern(), $this->getUri(), $matches)) {
$this->setPage((int) $matches[1]);
}
}

// get the current page from the URI
if (preg_match($this->buildPattern(), $this->getUri(), $matches)) {
return (int) $matches[1];
if ($this->page) {
return min($this->page, $this->getTotalPages());
}

// default page is 1
Expand Down