Pagination with rel="next" and rel="prev" support (#1551)

* Minor improvements

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-07-21 19:59:08 +07:00 committed by GitHub
commit a10ec4c394
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 3 deletions

View file

@ -1278,10 +1278,12 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
if ($add_prevnext_text) {
if ($on_page > 1) {
$page_string = ' <a href="' . $base_url . "&amp;start=" . (($on_page - 2) * $per_page) . '">' . $lang['PREVIOUS_PAGE'] . '</a>&nbsp;&nbsp;' . $page_string;
$meta_prev_link = FULL_URL . $base_url . "&amp;start=" . (($on_page - 2) * $per_page);
}
if ($on_page < $total_pages) {
$page_string .= '&nbsp;&nbsp;<a href="' . $base_url . "&amp;start=" . ($on_page * $per_page) . '">' . $lang['NEXT_PAGE'] . '</a>';
$meta_next_link = FULL_URL . $base_url . "&amp;start=" . ($on_page * $per_page);
}
}
@ -1295,7 +1297,10 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
'PAGINATION' => $pagination,
'PAGE_NUMBER' => sprintf($lang['PAGE_OF'], (floor($start_item / $per_page) + 1), ceil($num_items / $per_page)),
'PG_BASE_URL' => $base_url,
'PG_PER_PAGE' => $per_page
'PG_PER_PAGE' => $per_page,
// Assign meta
'META_PREV_PAGE' => $meta_prev_link ?? '',
'META_NEXT_PAGE' => $meta_next_link ?? '',
]);
return $pagination;