Skip to content

Commit e95a573

Browse files
committed
[ci skip] Updating user guide for extra pagination values.
1 parent 0eea4b2 commit e95a573

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

user_guide_src/source/libraries/pagination.rst

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,32 @@ methods to keep the data separate::
9090
<?= $pager->links('group1') ?>
9191
<?= $pager->simpleLinks('group2') ?>
9292

93+
Setting Page Manually
94+
=====================
95+
96+
If you need to specify which page of results to return you can specify the page as the 3rd argument. This can be
97+
handy when you have a different manner than the default $_GET varibable to control which page to show.
98+
99+
::
100+
101+
$userModel = new \App\Models\UserModel();
102+
$page = 3;
103+
104+
$users = $userModel->paginate(10, 'group1', $page);
105+
106+
Specifying the URI Segment for Page
107+
===================================
108+
109+
It is also possible to use a URI segment for the page number, instead of the page query parameter. Simply specify the
110+
segment number to use as the fourth argument. URIs generated by the pager would then look
111+
like *https://domain.tld/model/[pageNumber]* instead of *https://domain.tld/model?page=[pageNumber]*.::
112+
113+
::
114+
115+
$users = $userModel->paginate(10, 'group1', null, 3);
116+
117+
Please note: ``$segment`` value cannot be greater than the number of URI segments plus 1.
118+
93119
Manual Pagination
94120
=================
95121

@@ -102,13 +128,17 @@ the total number of items as the first, second, and third parameters, respective
102128
This will, by default, display the links in the normal manner, as a series of links, but you can change the display
103129
template used by passing in the name of the template as the fourth parameter. More details can be found in the following
104130
sections.
131+
105132
::
106133

107134
<?= $pager->makeLinks($page, $perPage, $total, 'template_name') ?>
108135

109-
It is also possible to use a URI segment for the page number, instead of the page query parameter. Simply specify the segment number to use as the fifth parameter to ``makeLinks()``. URIs generated by the pager would then look like *https://domain.tld/model/[pageNumber]* instead of *https://domain.tld/model?page=[pageNumber]*.::
136+
It is also possible to use a URI segment for the page number, instead of the page query parameter, as described in
137+
the previous section. Specify the segment number to use as the fifth parameter to ``makeLinks()``.
138+
139+
::
110140

111-
<?= $pager->makeLinks($page, $perPage, $total, 'template_name', $segment) ?>
141+
<?= $pager->makeLinks($page, $perPage, $total, 'template_name', $segment) ?>
112142

113143
Please note: ``$segment`` value cannot be greater than the number of URI segments plus 1.
114144

@@ -118,7 +148,7 @@ If you in need to show many pagers on one page then additional parameter which w
118148
$pager->setPath('path/for/my-group', 'my-group'); // Additionally you could define path for every group.
119149
$pager->makeLinks($page, $perPage, $total, 'template_name', $segment, 'my-group');
120150

121-
Pagination library uses *page* query parameter for HTTP queries by default (if no group or *default* group name given) or *page_[groupName]* for custom group names.
151+
Pagination library uses *page* query parameter for HTTP queries by default (if no group or *default* group name given) or *page_[groupName]* for custom group names.
122152

123153
Paginating with Only Expected Queries
124154
=====================================

0 commit comments

Comments
 (0)