Skip to content

Commit 11c2ec0

Browse files
committed
pager: override page if there's nothing to display
1 parent 5b9398d commit 11c2ec0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Skeleton/Pager/Pager.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,14 @@ public function page($all = false) {
587587

588588
$this->items = call_user_func_array([$this->classname, 'get_paged'], $params);
589589
$this->item_count = call_user_func_array([$this->classname, 'count'], [$this->options['conditions'], $this->options['joins']]);
590+
591+
// The requested page is empty, so we have probably passed the last item
592+
// page to the last page instead
593+
if (count($this->items) === 0 && $this->item_count > 0) {
594+
$this->options['page'] = ceil($this->item_count / $this->options['per_page']);
595+
$params[2] = $this->options['page'];
596+
$this->items = call_user_func_array([$this->classname, 'get_paged'], $params);
597+
}
590598
}
591599

592600
/**

0 commit comments

Comments
 (0)