Page links
The page and rows options cut one page out of a tag's rows. The {pager} tag writes the links to the other pages: the first and the last page, a window of pages on each side of the current one, a gap where pages are left out, and previous and next. The current page is marked aria-current="page".
|
PHP fragments/pager_1.php |
HTML fragments/pager_1.pad |
Result |
|---|---|---|
|
|
11 12 13 14 15 |
The pager reads what the paged tag left, so it comes after it, and names it - without a name it follows the last paged tag of the page. It counts the rows that the options written before page left, so a where in front of the page pages the rows that pass. window is the number of pages on each side of the current one, 2 when not given.
The links
Each link is built from the application's own address, so a mount prefix keeps working, and keeps the other values of the request - a search field stays on every page. The value it sets is the variable page= was written with: page=$pg links with pg=, and query='p' on the pager names another. On a first visit the value is not there yet, hence $pg ?? 1.
Markup of your own
Written as a pair, the pager hands the links over as rows instead: $kind is prev, next, page, current or gap, with $page, $label and $href - empty for a gap, and for a previous or next that does not exist. With a single page there are no rows, and the pair shows its @else@.
|
PHP fragments/pager_2.php |
HTML fragments/pager_2.pad |
Result |
|---|---|---|
|
|
‹ 1 2 3 4 5 › |
A Select table is paged by its SQL limit, so the rows do not hold the total: the pager then counts with one more query, and only when it is there.