Created
October 4, 2022 08:47
-
-
Save dlyamkin/6d5e2cf344a278e9594867ef006cb5f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/addons/blog/controllers/frontend/pages.post.php b/app/addons/blog/controllers/frontend/pages.post.php | |
index 066c72e6fc..ccf8b96ed8 100644 | |
--- a/app/addons/blog/controllers/frontend/pages.post.php | |
+++ b/app/addons/blog/controllers/frontend/pages.post.php | |
@@ -24,10 +24,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
if ($mode == 'view') { | |
$page_data = Tygh::$app['view']->getTemplateVars('page'); | |
+ $is_pagination = !empty($_REQUEST['page']); | |
if ($page_data['page_type'] == PAGE_TYPE_BLOG) { | |
- list($subpages, $search) = fn_get_pages(array( | |
+ list($subpages, $search) = fn_get_pages([ | |
'parent_id' => $page_data['page_id'], | |
'page' => !empty($_REQUEST['page']) ? $_REQUEST['page'] : 0, | |
'page_type' => PAGE_TYPE_BLOG, | |
@@ -35,7 +36,14 @@ if ($mode == 'view') { | |
'status' => 'A', | |
'sort_by' => 'timestamp', | |
'sort_order' => 'desc' | |
- ), Registry::get('settings.Appearance.elements_per_page')); | |
+ ], Registry::get('settings.Appearance.elements_per_page')); | |
+ | |
+ if ( | |
+ empty($subpages) | |
+ && $is_pagination | |
+ ) { | |
+ return [CONTROLLER_STATUS_NO_PAGE]; | |
+ } | |
Tygh::$app['view']->assign('subpages', $subpages); | |
Tygh::$app['view']->assign('search', $search); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/functions/fn.cms.php b/app/functions/fn.cms.php | |
index 31e385f81b..3761754e4c 100644 | |
--- a/app/functions/fn.cms.php | |
+++ b/app/functions/fn.cms.php | |
@@ -329,7 +329,7 @@ function fn_get_pages($params = array(), $items_per_page = 0, $lang_code = CART_ | |
if (!empty($params['items_per_page'])) { | |
$params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:pages.page_id)) FROM ?:pages ?p WHERE ?p ?p ?p", $join, $condition, $group_by, $sorting); | |
- $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']); | |
+ $limit = db_paginate($params['page'], $params['items_per_page']); | |
} | |
$pages = db_get_hash_array("SELECT " . implode(', ', $fields) ." FROM ?:pages ?p WHERE ?p ?p ?p ?p", 'page_id', $join, $condition, $group_by, $sorting, $limit); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment