From a10ec4c39487e7862afa6b4a47996f36587fa2c2 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 21 Jul 2024 19:59:08 +0700 Subject: [PATCH] Pagination with `rel="next"` and `rel="prev"` support (#1551) * Minor improvements * Update CHANGELOG.md --- CHANGELOG.md | 1 + library/includes/functions.php | 7 ++++++- styles/templates/default/page_header.tpl | 6 ++++++ styles/templates/default/usercp_topic_watch.tpl | 2 +- styles/templates/default/viewforum.tpl | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66acebde8..7ea344bd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Fixed broken "Disable Board" function [\#1529](https://github.com/torrentpier/torrentpier/pull/1529) ([belomaxorka](https://github.com/belomaxorka)) - Fixed seed bonus accrual [\#1518](https://github.com/torrentpier/torrentpier/pull/1518) ([belomaxorka](https://github.com/belomaxorka)) - [BETA] Added emojis support 😄😁 [\#1514](https://github.com/torrentpier/torrentpier/pull/1514) ([belomaxorka](https://github.com/belomaxorka)) +- Pagination with `rel="next"` and `rel="prev"` support [\#1551](https://github.com/torrentpier/torrentpier/pull/1551) ([belomaxorka](https://github.com/belomaxorka)) - Datastore improvements [\#1538](https://github.com/torrentpier/torrentpier/pull/1538) ([belomaxorka](https://github.com/belomaxorka)) - Resize user/group avatar image if too large 🌆 [\#1512](https://github.com/torrentpier/torrentpier/pull/1512) ([belomaxorka](https://github.com/belomaxorka)) - Increased PASSWORD_MAX_LENGTH [\#1510](https://github.com/torrentpier/torrentpier/pull/1510) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/library/includes/functions.php b/library/includes/functions.php index 0188bcdc7..6a4ef5aae 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -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 = ' ' . $lang['PREVIOUS_PAGE'] . '  ' . $page_string; + $meta_prev_link = FULL_URL . $base_url . "&start=" . (($on_page - 2) * $per_page); } if ($on_page < $total_pages) { $page_string .= '  ' . $lang['NEXT_PAGE'] . ''; + $meta_next_link = FULL_URL . $base_url . "&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; diff --git a/styles/templates/default/page_header.tpl b/styles/templates/default/page_header.tpl index 9a7febee5..8d8d24ba5 100644 --- a/styles/templates/default/page_header.tpl +++ b/styles/templates/default/page_header.tpl @@ -11,6 +11,12 @@ + + + + + + {META} diff --git a/styles/templates/default/usercp_topic_watch.tpl b/styles/templates/default/usercp_topic_watch.tpl index dd8629913..48d2e2e76 100644 --- a/styles/templates/default/usercp_topic_watch.tpl +++ b/styles/templates/default/usercp_topic_watch.tpl @@ -77,7 +77,7 @@
-

{PAGE_TITLE}

+

{PAGE_TITLE}

{FORUM_NAME}

-

{FORUM_DESC}

+

{FORUM_DESC}

{L_MODERATORS}