aboutsummaryrefslogtreecommitdiffstats
path: root/core/functions.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-07-01 21:25:43 +0200
committerThomas Lange <code@nerdmind.de>2021-07-01 21:25:43 +0200
commitf1d09d8cdc6e4a1ed0fb44544b368c6632bbd379 (patch)
treebe2c9aa922f61b825e8ba9f9333b7f27e5407161 /core/functions.php
parente6cef37e0c782fe770db20888d99c17d10e2c479 (diff)
downloadblog-f1d09d8cdc6e4a1ed0fb44544b368c6632bbd379.tar.gz
blog-f1d09d8cdc6e4a1ed0fb44544b368c6632bbd379.tar.xz
blog-f1d09d8cdc6e4a1ed0fb44544b368c6632bbd379.zip
Add function generateCategoryPostNaviTemplate
Add and use the function generateCategoryPostNaviTemplate to build the pagination template for posts in a category. This fixes a mistake. TODO: Get rid of that confusing function mess!
Diffstat (limited to 'core/functions.php')
-rw-r--r--core/functions.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/functions.php b/core/functions.php
index ea4b7eb..3282f1c 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -54,6 +54,24 @@ function generateCategoryNaviTemplate($current): Template {
}
#===============================================================================
+# Generate the post navigation template for posts in a category
+#===============================================================================
+function generateCategoryPostNaviTemplate(int $current, Category $Category): Template {
+ $location = Application::getEntityURL($Category);
+ $Repository = Application::getRepository('Post');
+
+ $listSize = Application::get('POST.LIST_SIZE');
+ $lastSite = ceil($Repository->getCountByCategory($Category) / $listSize);
+
+ $PaginationTemplate = TemplateFactory::build('pagination');
+ $PaginationTemplate->set('THIS', $current);
+ $PaginationTemplate->set('LAST', $lastSite);
+ $PaginationTemplate->set('HREF', "{$location}?site=%d");
+
+ return $PaginationTemplate;
+}
+
+#===============================================================================
# Helper function to reduce duplicate code
#===============================================================================
function generateCategoryItemTemplate(Category $Category, bool $is_root = FALSE): Template {