Skip to content

Commit

Permalink
Add a documentation and also improve some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
murilohpucci committed Jan 6, 2025
1 parent f369cb9 commit 9878718
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
6 changes: 3 additions & 3 deletions system/Pager/PagerRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ class PagerRenderer
protected $pageSelector;

/**
* The maximum number of items displayed per page.
* Returns the number of results per page that should be shown.
*/
protected ?int $perPage;

/**
* The index of the first item on the current page.
* The number of items the page starts with.
*/
protected ?int $perPageStart;

/**
* The index of the last item on the current page.s
* The number of items the page ends with.
*/
protected ?int $perPageEnd;

Expand Down
25 changes: 25 additions & 0 deletions user_guide_src/source/libraries/pagination.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,28 @@ getPageCount()
--------------

This method returns total number of pages.

Displaying the Number of Items on the Page
==========================================

.. warning:: The methods `getTotal()`, `getPerPage()`, `getPerPageStart()`, and `getPerPageEnd()` were introduced in v4.6.0.

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:

.. literalinclude:: pagination/019.php

getTotal()
----------
Returns the total items of the page.

getPerPage()
------------
Returns the number of items to be displayed on the page.

getPerPageStart()
-----------------
Returns the number of items the page starts with.

getPerPageEnd()
---------------
Returns the number of items the page ends with.
7 changes: 7 additions & 0 deletions user_guide_src/source/libraries/pagination/019.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php $pager->setSurroundCount(1) ?>

<p>
Showing <span class="font-medium"><?= $pager->getPerPageStart() ?></span>
to <span class="font-medium"><?= $pager->getPerPageEnd() ?></span>
of <span class="font-medium"><?= $pager->getTotal() ?></span> results
</p>

0 comments on commit 9878718

Please sign in to comment.