Hey together,
currently I’m struggeling to create a featured article post for a project.
This means that the featured article is selected inside the panel and should appear on the page ‘Blog’ at the top as the first article. The presentation of the article at the top and the selection of the article with the help of the multiselect plugins works so far.
Now I would like to realize that the featured article will only be displayed once and not again between all the other articles. In addition, unfortunately I do not know how I run the pagination correct. Cause right now the featured article will be displayed on every page when I use the pagination. Maybe someone had to face the same problem…
Thanks!
<?php
$perpage = $page->perpage()->int();
$articles = $pages->find('blog')->children()->visible()->flip()->paginate($perpage);
$last = $articles->last();
$pagination = $articles->pagination();
?>
<!-- Featured Article -->
<?php foreach($page->featured()->pages(',') as $f): ?>
<div class="box">
<h2><?= $f->title() ?></h2>
<p><?= excerpt($f->text(), 300) ?></p>
</div>
<?php endforeach ?>
<!-- All Articles -->
<?php foreach($articles as $article): // article overview ?>
<?php if($page->featured()->pages(',') != ''): ?>
<h2><?= $article->title() ?></h2>
<p><?= excerpt($article->text(), 300) ?></p>
<?php endif ?>
<?php endforeach ?>
<!-- Pagination -->
<nav>
<ul >
<?php if($pagination->hasPrevPage()): ?>
<li><a href="<?= $pagination->prevPageURL() ?>">Newer</a></li>
<?php endif ?>
<?php foreach($pagination->range(3) as $r): ?>
<li>
<a class="pagination-link<?php if($pagination->page() == $r) echo ' is-current' ?>" href="<?= $pagination->pageURL($r) ?>"><?= $r ?></a>
</li>
<?php endforeach ?>
<?php if($pagination->hasNextPage()): ?>
<li><a href="<?= $pagination->nextPageURL() ?>">Older</a></li>
<?php endif ?>
</ul>
</nav>