Hello! For a site with lots of articles I want to display the latest 15 articles, interspersed with other content, on the homepage. I’m looking to create a structure like this:
[Banner]
[Chunk of 3 articles]
[Banner]
[Chunk of 3 articles]
[Chunk of 3 articles]
[Support]
[Chunk of 3 articles]
[Chunk of 3 articles]
[Newsletter]
But am not sure how to go about saving/splitting up the chunked collection so that I might insert content between chunks:
// Adapted from another post on the forum
<?php $projects = $articles;
$chunks = $projects->limit(15)->chunk(3); ?>
<section class="articles-recent">
<?php foreach($chunks as $items): ?>
<div>
<?php foreach($items as $project): ?>
<a href="<?= $project->url() ?>">
<imgsrc="<?= $project->coverimage()->toFile()->url() ?>" alt="" />
</a>
<?php endforeach; ?>
</div>
<?php endforeach ?>
</section>
So having each chunk as something I can loop through independently.
Is this possible? Is chunk() the right way to approach this?
Thank you!