cms39_paginate() handles pagination in one call: it counts, fetches the items of the current page and builds the HTML. It uses Pagerfanta underneath.
$r = cms39_paginate([
'sql' => 'SELECT mod_blog_cat_id FROM cms39_posts WHERE mod_blog_cat_type = ? AND mod_blog_cat_status = 1 ORDER BY mod_blog_cat_date DESC',
'params' => ['post'],
], 12, ['page' => the_id(), 'window' => 5]);
foreach ($r['items'] as $row) {
$post = PageDetail($row['mod_blog_cat_id']);
}
echo $r['html']; // ‹ 1 2 3 4 5 ›Sources
- SQL with parameters (the count is derived automatically, correct even with GROUP BY)
- Doctrine QueryBuilder
- two functions:
['count' => fn() => …, 'items' => fn($offset, $length) => …] - an array you already have
Returns items, html, total, page, last. An out-of-range page (?page=999) shows the last one; a non-number shows the first. The HTML uses the same classes as the rest of the site, or 'view' => 'bootstrap5'.
E-MAIL or by phone at (+30) +30.2152151245-8