@@ -18,9 +18,11 @@ to load it manually:
1818
1919.. literalinclude :: pagination/001.php
2020
21- ***************************
22- Paginating Database Results
23- ***************************
21+ .. _paginating-with-models :
22+
23+ **********************
24+ Paginating with Models
25+ **********************
2426
2527In most cases, you will be using the Pager library in order to paginate results that you retrieve from the database.
2628When using the :doc: `Model </models/model >` class, you can use its built-in ``paginate() `` method to automatically
@@ -37,8 +39,8 @@ The first element is the results from the database, **users**, which is retrieve
3739the Model will hold on to the instance it used and store it in the public property, ``$pager ``. So, we grab
3840that and assign it to the ``$pager `` variable in the view.
3941
40- .. important :: It is important to understand that the Model::paginate() method uses the Model and QueryBuilder methods.
41- Therefore, trying to use ``$db->query() `` and Model::paginate() **will not work ** because ``$db->query() `` executes
42+ .. important :: It is important to understand that the `` Model::paginate()`` method uses the ** Model** and ** QueryBuilder** methods.
43+ Therefore, trying to use ``$db->query() `` and `` Model::paginate() `` **will not work ** because ``$db->query() `` executes
4244 the query immediately and is not associated with a QueryBuilder.
4345
4446To define conditions for pagination in a model, you can:
@@ -91,29 +93,26 @@ like **https://domain.tld/foo/bar/[pageNumber]** instead of **https://domain.tld
9193
9294Please note: ``$segment `` value cannot be greater than the number of URI segments plus 1.
9395
96+ *****************
9497Manual Pagination
95- =================
98+ *****************
9699
97100You may find times where you just need to create pagination based on known data. You can create links manually
98101with the ``makeLinks() `` method, which takes the current page, the number of results per page, and
99- the total number of items as the first, second, and third parameters, respectively::
102+ the total number of items as the first, second, and third parameters, respectively:
100103
101- <?= $pager->makeLinks($page, $perPage, $total) ?>
104+ .. literalinclude :: pagination/015.php
102105
103106This will, by default, display the links in the normal manner, as a series of links, but you can change the display
104107template used by passing in the name of the template as the fourth parameter. More details can be found in the following
105- sections.
108+ sections::
106109
107- ::
108-
109- <?= $pager->makeLinks($page, $perPage, $total, 'template_name') ?>
110+ $pager->makeLinks($page, $perPage, $total, 'template_name');
110111
111112It is also possible to use a URI segment for the page number, instead of the page query parameter, as described in
112- the previous section. Specify the segment number to use as the fifth parameter to ``makeLinks() ``.
113-
114- ::
113+ the previous section. Specify the segment number to use as the fifth parameter to ``makeLinks() ``::
115114
116- <?= $pager->makeLinks($page, $perPage, $total, 'template_name', $segment) ?>
115+ $pager->makeLinks($page, $perPage, $total, 'template_name', $segment);
117116
118117Please note: ``$segment `` value cannot be greater than the number of URI segments plus 1.
119118
@@ -123,8 +122,9 @@ If you in need to show many pagers on one page then additional parameter which w
123122
124123Pagination 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.
125124
125+ *************************************
126126Paginating with Only Expected Queries
127- =====================================
127+ *************************************
128128
129129By default, all GET queries are shown in the pagination links.
130130
0 commit comments