diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/functions.php | 18 | ||||
-rw-r--r-- | core/include/category/main.php | 2 |
2 files changed, 19 insertions, 1 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 { diff --git a/core/include/category/main.php b/core/include/category/main.php index 57f8625..1f9adf7 100644 --- a/core/include/category/main.php +++ b/core/include/category/main.php @@ -111,7 +111,7 @@ $CategoryTemplate->set('COUNT', [ $CategoryTemplate->set('PAGINATION', [ 'THIS' => $currentSite, 'LAST' => $lastSite, - 'HTML' => generatePostNaviTemplate($currentSite) + 'HTML' => generateCategoryPostNaviTemplate($currentSite, $Category) ]); $CategoryTemplate->set('LIST', [ 'POSTS' => $post_templates ?? [], |