I’ve been over this a bunch of times now. I’m following the pagination documented on the kirby website but when i skip to my second page it shows items from the first page.
This is my code:
<div class="col-md-1 content-block"></div>
<div class="col-md-10 content-block">
<ul class="events-list">
<?php
$list = $page->children()->paginate(3);
$pagination = $list->pagination();
$i = 0;
foreach($list as $item): ?>
<li class="event-list-item">
<?php $calendar = $page->children()->nth($i)->calendar()->yaml();
foreach($calendar as $calendarEntry): ?>
<span class="event-date">
<span class="date">
<?php
$eventday=strtotime($calendarEntry['_begin_date']);
echo date('j',$eventday);
?>
</span>
<span class="month">
<?php
$eventmonth=strtotime($calendarEntry['_begin_date']);
echo date('M',$eventmonth);
?>
</span>
<span class="year">
<?php
$eventmonth=strtotime($calendarEntry['_begin_date']);
echo date('Y',$eventmonth);
?>
</span>
</span>
<div class="event-list-cont">
<span class="meta-data">Starts:
<?php $eventday=strtotime($calendarEntry['_begin_date']);
echo date('l',$eventday); ?>,
<?php $eventstarttime=strtotime($calendarEntry['_begin_time']);
echo date('g:i A',$eventstarttime); $eventday=strtotime($calendarEntry['_end_date']);
if ($eventday){ ?>
| Finishes: <?php echo date('l',$eventday); ?>,
<?php } ?>
<?php $eventendtime=strtotime($calendarEntry['_end_time']);
if($eventendtime) {
echo date('g:i A',$eventendtime);
} ?></span>
<h4 class="post-title"><a href="<?php echo page('events')->children()->nth($i)->url(); ?>"><?php echo $calendarEntry['eventname'] ?></a></h4>
<p>
<?php echo page('events')->children()->nth($i)->eventwriteup()->excerpt(250); ?> <a href="<?php echo page('events')->children()->nth($i)->url(); ?>">read more →</a>
</p>
</div>
<?php $i++; ?>
<?php endforeach; ?>
</li>
<?php endforeach; ?>
</ul>
<!-- Page Pagination -->
<nav>
<ul class="pagination pagination-lg">
<?php if($pagination->hasPrevPage()): ?>
<li>
<a href="<?php echo $pagination->prevPageURL() ?>">←</a></li>
<?php else: ?>
<li><span>←</span></li>
<?php endif ?>
<?php foreach($pagination->range(10) as $r): ?>
<li><a<?php if($pagination->page() == $r) echo ' class="active"' ?> href="<?php echo $pagination->pageURL($r) ?>"><?php echo $r ?></a></li>
<?php endforeach ?>
<?php if($pagination->hasNextPage()): ?>
<li class="last"><a href="<?php echo $pagination->nextPageURL() ?>">→</a></li>
<?php else: ?>
<li class="last"><span>→</span></li>
<?php endif ?>
</ul>
</nav>
</div>
Does the Issue have something to do with calling the loop for the calendar plugin data within the events-list loop? Any advice much appreciated