The framework pager: common()->divide_pages() takes an SQL query, a query builder or
an array and returns the rows (or the LIMIT) of the current page with the page links; table2 pages with it
too (pager_records_on_page, see the table demo).
Here it pages the 20 sample products in memory. slide keeps the current page in the middle of the
visible numbers, blocks shows fixed blocks with jumps to the previous / next block. The options come from fixed lists
and the page number is clamped, so ?page=999 shows the last page; the links work without JavaScript.
Classes: yf_divide_pages, yf_common, yf_html (pagination()).
common()->divide_pages()
| # | Name | Colour | Price |
|---|---|---|---|
| 10 | Paint Bucket T-shirt, purple | purple | 37.00 |
| 11 | Flash T-shirt, white | white | 35.00 |
| 12 | Mix Tape T-shirt, black | black | 45.00 |
Products 10–12 of 20, page 4 of 7
[$items, $pages_html, $total, $first, $total_pages] = common()->divide_pages(
$rows, $url, 'slide', 3, 0, '', 0,
[
'requested_page' => $page,
'pages_per_block' => 5,
'add_get_vars' => 0,
]
);The bare widget: html()->pagination()
The same state drawn by html()->pagination($links, $extra): you pass page => link pairs plus prev /
next, and the options current, disabled, size and align; it computes nothing itself.
Under ?bs=5 it renders Bootstrap 5 markup (yf_html_bs5),
under ?bs=3 Bootstrap 3.