But that would happen automatically if you paginate your $sorted collection. Why the two collections? With paginate(3) you get 3 items per page, so the first 3 would be on the first page.
Moving the paginate to my sorted doesn’t achieve what I want, because a featured block still shows up on page 2.
Example bellow, the HTML comments say what I want to achieve.
Template
<!-- ONLY SHOW THIS BLOCK ON PAGE ONE -->
<?php if ($featured->count()): ?>
<div class="o-featured">
<?php foreach ($featured as $item): ?>
<article class="o-featured__article">
</article>
<?php endforeach ?>
</div>
<?php endif ?>
<!-- THIS IS THE NORMAL ARTICLE LIST WHICH IS PAGINATED -->
<?php if ($note->count()): ?>
<div class="o-note">
<?php foreach ($note as $item): ?>
<article class="o-note__article">
</article>
<?php endforeach ?>
</div>
<?php snippet('pagination') ?>
<?php else: ?>
<div class="o-noresults">
<h3 class="o-noresults__title"><?= t('nonotestitle') ?></h3>
<p class="o-noresults__text"><?= t('nonotestext') ?></p>
</div>
<?php endif ?>
So my attempt was using the original collection ‘sorted’, take the first items and register them under a different name ‘featured’, inject them into their own HTML block, then exclude ‘featured’ from my ‘note’ collection and paginate my ‘note’ collection like I normally would.
The way I achieved something similar was on my albums page where I just used a different class for the first item but only wanted that class on page one.
You can check for your pagination page and only display the featured block when on page one.
In your controller, define the pagination object:
$pagination = $note->pagination();
In template:
<?php if ($pagination->isFirstPage()): ?>
<!-- ONLY SHOW THIS BLOCK ON PAGE ONE -->
<?php if ($featured->count()): ?>
<div class="o-featured">
<?php foreach ($featured as $item): ?>
<article class="o-featured__article">
</article>
<?php endforeach ?>
</div>
<?php endif ?>
<?php endif ?>