php - Cakephp retrieves pages over limit -


i'm using cakephp 1.3 paginator, works fine, except this:

if have 5 pages, accessing kind of url

http://example.com/blog/5

i'll last page, if access to

http://example.com/blog/10

i last page. want not retrieve values, since not valid page.

my configuration this:

  var $paginate = array(         'post' => array(             'limit' => 10,             'order' => array('post.id' => 'desc')                    )      );  $posts = $this->paginate('post'); 

well, that's unfortunately how works until cakephp 2.3, , it's buried in middle of controller::paginate() method:

https://github.com/cakephp/cakephp/blob/1.3.20/cake/libs/controller/controller.php#l1214-l1215

// ...  if ($page === 'last' || $page >= $pagecount) {     $options['page'] = $page = $pagecount;  // ... 

so pretty have 1 option, calculate page count , use validate current page.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -