Hi there.
My problem:
I have a blog.php
template (and a blog.php
controller) who displays my blogposts or sort them per category.
When i reach my pagination limit i can see my pagination nav but get a 404 error when i click on older posts.
My category list then shows the pagination too, even if the pagination limit is not reached for the displayed articles per category.
There is no error in debug mode.
My code:
I have the following code in my template blog.php
:
<?php if($pagination->hasPages()): ?>
<nav class="pagination">
<?php if($pagination->hasNextPage()): ?>
<a href="<?= $pagination->nextPageURL() ?>" class="pagination__older">Ältere Einträge</a>
<?php endif ?>
<?php if($pagination->hasPrevPage()): ?>
<a href="<?= $pagination->prevPageURL() ?>" class="pagination__newer">Neuere Einträge</a>
<?php endif ?>
</nav>
<?php endif ?>
Then i have the controller blog.php
:
<?php
return function($site, $pages, $page) {
// Kategorien
$category = urldecode(param('category'));
$articlesByCategory = $pages->index()
->visible()
->filterBy('category', $category)
->flip()
->paginate(10);
// Artikel
$articles = $pages->index()
->visible()
->filterBy('template', 'post.article' && 'post.link' && 'post.image' && 'post.status')
->flip()
->paginate(10);
return array(
'category' => $category,
'articlesByCategory' => $articlesByCategory,
'articles' => $articles,
'pagination' => $articles->pagination()
);
};