Skip to content

Commit c9b641f

Browse files
committed
Add example of setting view vars, make note that _serialize should be an array
1 parent af71379 commit c9b641f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ Then, load `ApiPaginationComponent`:
3434
$this->loadComponent('BryanCrowe/ApiPagination.ApiPagination');
3535
```
3636

37+
Then, go ahead and set your paginated view variable like so:
38+
39+
``` php
40+
$this->set('articles', $this->paginate($this->Articles));
41+
$this->set('_serialize', ['articles']);
42+
```
43+
44+
**Note:** It is important that your `_serialize` variable is an array, e.g.
45+
`['articles']`, so that your pagination information can be set under its own
46+
pagination key.
47+
3748
Your JsonView and XmlView responses will now contain the pagination information,
3849
and will look something like this:
3950

0 commit comments

Comments
 (0)