Skip to content

Commit 9878718

Browse files
committed
Add a documentation and also improve some comments.
1 parent f369cb9 commit 9878718

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

system/Pager/PagerRenderer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ class PagerRenderer
8383
protected $pageSelector;
8484

8585
/**
86-
* The maximum number of items displayed per page.
86+
* Returns the number of results per page that should be shown.
8787
*/
8888
protected ?int $perPage;
8989

9090
/**
91-
* The index of the first item on the current page.
91+
* The number of items the page starts with.
9292
*/
9393
protected ?int $perPageStart;
9494

9595
/**
96-
* The index of the last item on the current page.s
96+
* The number of items the page ends with.
9797
*/
9898
protected ?int $perPageEnd;
9999

user_guide_src/source/libraries/pagination.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,28 @@ getPageCount()
340340
--------------
341341

342342
This method returns total number of pages.
343+
344+
Displaying the Number of Items on the Page
345+
==========================================
346+
347+
.. warning:: The methods `getTotal()`, `getPerPage()`, `getPerPageStart()`, and `getPerPageEnd()` were introduced in v4.6.0.
348+
349+
When paginating items, it’s often helpful to display the total number of items and the range of items shown on the current page. To simplify this task, new methods have been added. These methods make it easier to manage and display pagination details. Here's an example:
350+
351+
.. literalinclude:: pagination/019.php
352+
353+
getTotal()
354+
----------
355+
Returns the total items of the page.
356+
357+
getPerPage()
358+
------------
359+
Returns the number of items to be displayed on the page.
360+
361+
getPerPageStart()
362+
-----------------
363+
Returns the number of items the page starts with.
364+
365+
getPerPageEnd()
366+
---------------
367+
Returns the number of items the page ends with.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php $pager->setSurroundCount(1) ?>
2+
3+
<p>
4+
Showing <span class="font-medium"><?= $pager->getPerPageStart() ?></span>
5+
to <span class="font-medium"><?= $pager->getPerPageEnd() ?></span>
6+
of <span class="font-medium"><?= $pager->getTotal() ?></span> results
7+
</p>

0 commit comments

Comments
 (0)