Skip to content
This repository
Browse code

Added info about exception thrown in PaginatorComponent

  • Loading branch information...
commit 70de2d7e03073a06a87b0928a6c6838dee95abe0 1 parent 85258f8
ADmad authored December 28, 2012
3  en/appendices/2-3-migration-guide.rst
Source Rendered
@@ -39,6 +39,9 @@ PaginatorComponent
39 39
   specify what find method you want used for pagination.  This is a bit easier
40 40
   to manage and set than the 0'th index.
41 41
 
  42
+- PaginatorComponent now throws a `NotFoundException` when trying to access a page
  43
+  which is out of range (i.e. requested page is greater than total page count).
  44
+
42 45
 SecurityComponent
43 46
 -----------------
44 47
 
18  en/core-libraries/components/pagination.rst
Source Rendered
@@ -206,6 +206,7 @@ the keyword in controller's ``$paginate`` class variable::
206 206
                 'group' => array('week', 'home_team_id', 'away_team_id')
207 207
             )
208 208
         );
  209
+    }
209 210
 
210 211
 In CakePHP 2.0, you no longer need to implement ``paginateCount()`` when using
211 212
 group clauses.  The core ``find('count')`` will correctly count the total number
@@ -294,6 +295,23 @@ arguments.
294 295
 
295 296
     Either of these approaches will solve the notice errors.
296 297
 
  298
+Out of range page requests
  299
+==========================
  300
+As of 2.3 the PaginatorComponent will throw a `NotFoundException` when trying to
  301
+access a non-existent page, i.e. page number requested is greater than total
  302
+page count.
  303
+
  304
+So you could either let the normal error page be rendered or use a try catch
  305
+block and take appropriate action when a `NotFoundException` is caught.
  306
+
  307
+    public function index() {
  308
+        try {
  309
+            $this->paginate();
  310
+        } catch (NotFoundException $e) {
  311
+            //Do something here like redirecting to first or last page.
  312
+            //$this->request->params['paging'] will give you required info.
  313
+        }
  314
+    }
297 315
 
298 316
 AJAX Pagination
299 317
 ===============

0 notes on commit 70de2d7

Please sign in to comment.
Something went wrong with that request. Please try again.