You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/libraries/pagination.rst
+44-15Lines changed: 44 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -227,32 +227,39 @@ setSurroundCount()
227
227
In the first line, the ``setSurroundCount()`` method specifies than we want to show two links to either side of
228
228
the current page link. The only parameter that it accepts is the number of links to show.
229
229
230
+
.. note:: You must call this method first to generate correct pagination links.
231
+
230
232
hasPrevious() & hasNext()
231
233
-------------------------
232
234
233
-
These methods return a boolean true if there are more links that can be displayed on either side of the current page,
234
-
based on the value passed to ``setSurroundCount()``. For example, let's say we have 20 pages of data. The current
235
-
page is page 3. If the surrounding count is 2, then the following links would show up in the list: 1, 2, 3, 4, and 5.
236
-
Since the first link displayed is page one, ``hasPrevious()`` would return **false** since there is no page zero. However,
237
-
``hasNext()`` would return **true** since there are 15 additional pages of results after page five.
235
+
These methods return a boolean ``true`` if there are more links that can be displayed on either side of the current page,
236
+
based on the value passed to `setSurroundCount()`_.
237
+
238
+
For example, let's say we have 20 pages of data. The current
239
+
page is page 3. If the surrounding count is 2, then the following links would show up like this::
240
+
241
+
1 | 2 | 3 | 4 | 5
242
+
243
+
Since the first link displayed is page one, ``hasPrevious()`` would return ``false`` since there is no page zero. However,
244
+
``hasNext()`` would return ``true`` since there are 15 additional pages of results after page five.
238
245
239
246
getPrevious() & getNext()
240
247
-------------------------
241
248
242
-
These methods return the URL for the previous or next pages of results on either side of the numbered links.
249
+
These methods return the **URL** for the previous or next pages of results on either side of the numbered links.
243
250
244
251
For example, you have the current page set at 5 and you want to have the links before and after (the surroundCount) to be 2 each, that will give you something like this::
245
252
246
253
3 | 4 | 5 | 6 | 7
247
254
248
255
``getPrevious()`` returns the URL for page 2. ``getNext()`` returns the URL for page 8.
249
256
250
-
If you want to get page 4 and page 6, use ``getPreviousPage()`` and ``getNextPage()`` instead.
257
+
If you want to get page 4 and page 6, use `getPreviousPage() & getNextPage()`_ instead.
251
258
252
259
getFirst() & getLast()
253
260
----------------------
254
261
255
-
Much like ``getPrevious()`` and ``getNext()``, these methods return links to the first and last pages in the
262
+
Much like `getPrevious() & getNext()`_, these methods return the **URL** to the first and last pages in the
256
263
result set.
257
264
258
265
links()
@@ -263,9 +270,9 @@ title, which is just the number, and a boolean that tells whether the link is th
263
270
264
271
.. literalinclude:: pagination/013.php
265
272
266
-
In the code presented for the standard pagination structure, the methods ``getPrevious()`` and ``getNext()`` are used to obtain the links to the previous and next pagination groups respectively.
273
+
In the code presented for the standard pagination structure, the methods `getPrevious() & getNext()`_ are used to obtain the links to the previous and next pagination groups respectively.
267
274
268
-
If you want to use the pagination structure where prev and next will be links to the previous and next pages based on the current page, just replace the ``getPrevious()`` and ``getNext()`` methods with ``getPreviousPage()`` and ``getNextPage()``, and the methods ``hasPrevious()`` and ``hasNext()`` by ``hasPreviousPage()`` and ``hasNextPage()`` respectively.
275
+
If you want to use the pagination structure where prev and next will be links to the previous and next pages based on the current page, just replace the `getPrevious() & getNext()`_ methods with `getPreviousPage() & getNextPage()`_, and the methods `hasPrevious() & hasNext()`_ by `hasPreviousPage() & hasNextPage()`_ respectively.
269
276
270
277
See following an example with these changes:
271
278
@@ -274,21 +281,35 @@ See following an example with these changes:
274
281
hasPreviousPage() & hasNextPage()
275
282
---------------------------------
276
283
277
-
This method returns a boolean true if there are links to a page before and after, respectively, the current page being displayed.
284
+
This method returns a boolean ``true`` if there are links to a page before and after, respectively, the current page being displayed.
285
+
286
+
For example, let's say we have 20 pages of data. The current
287
+
page is page 3. If the surrounding count is 2, then the following links would show up like this::
288
+
289
+
1 | 2 | 3 | 4 | 5
290
+
291
+
``hasPreviousPage()`` would return ``true`` since there is page 2. And,
292
+
``hasNextPage()`` would return ``true`` since there is page 4.
278
293
279
-
Their difference to ``hasPrevious()`` and ``hasNext()`` is that they are based on the current page while ``hasPrevious()`` and ``hasNext()`` are based on the set of links to be displayed before and after the current page based on the value passed in ``setSurroundCount()``.
294
+
.. note:: The difference to `hasPrevious() & hasNext()`_ is that they are based
295
+
on the current page while `hasPrevious() & hasNext()`_ are based on the set
296
+
of links to be displayed before and after the current page based on the value
297
+
passed in `setSurroundCount()`_.
280
298
281
299
getPreviousPage() & getNextPage()
282
300
---------------------------------
283
301
284
-
These methods return a URL for the previous and next pages in relation to the current page being displayed, unlike ``getPrevious()`` and ``getNext()`` that return the URL for the previous or next pages of results on either side of the numbered links. See the previous paragraph for a full explanation.
302
+
These methods return a **URL** for the previous and next pages in relation to the current page being displayed.
285
303
286
304
For example, you have the current page set at 5 and you want to have the links before and after (the surroundCount) to be 2 each, that will give you something like this::
287
305
288
306
3 | 4 | 5 | 6 | 7
289
307
290
308
``getPreviousPage()`` returns the URL for page 4. ``getNextPage()`` returns the URL for page 6.
291
309
310
+
.. note:: `getPrevious() & getNext()`_ returns the URL for the previous or next
311
+
pages of results on either side of the numbered links.
312
+
292
313
If you want page numbers instead of URLs, you can use the following methods:
293
314
294
315
getPreviousPageNumber() & getNextPageNumber()
@@ -299,8 +320,16 @@ These methods return the page number for the previous or next pages in relation
299
320
getFirstPageNumber() & getLastPageNumber()
300
321
------------------------------------------
301
322
302
-
These methods return page numbers to the first and last pages in the
303
-
result set.
323
+
These methods return the page numbers of the first and last pages in the set of
324
+
links to be displayed. For example, if the set of links to be displayed is something like this::
325
+
326
+
3 | 4 | 5 | 6 | 7
327
+
328
+
``getFirstPageNumber()`` will return 3 while ``getLastPageNumber()`` will return 7.
329
+
330
+
.. note:: To obtain the page numbers of the first and last pages in the entire
331
+
result set, you can use the following approach: The first page number is always 1, and `getPageCount()`_ can be used to
0 commit comments