So I have a home page with random content coming from some grandChildren.
I’m wondering if there is a way to simplify the code or use a controller maybe to have this content fill the page in this layout but not have any of the ‘projects’ repeat.
Any help or point in the right direction would be most appreciated!
<div class="mt-24">
<ul class="work mt-24 pb-24">
<?php foreach(page('work')->grandChildren()->shuffle()->limit(2) as $project): ?>
<li>
<figure>
<a href=" <?= $project->url() ?> ">
<?= $project->image()->crop(500, 300) ?>
<div class="post-info relative">
<figcaption class="ml-4">
<h2><?= $project->title() ?></h2>
<p class="project-tag">
<?php foreach ($project->tags() as $category): ?>
<?= $category ?>
<?php endforeach ?>
</p>
</figcaption>
</div>
</a>
</figure>
</li>
<?php endforeach ?>
</ul>
</div>
<div class="featured pb-24">
<?php foreach(page('work')->grandChildren()->shuffle()->limit(1) as $featured): ?>
<li>
<figure>
<a href=" <?= $featured->url() ?> ">
<?= $featured->image()->crop(700, 400) ?>
</a>
<div class="post-info relative">
<figcaption class="ml-4">
<h2><?= $featured->title() ?></h2>
<p class="project-tag">
<?php foreach ($featured->tags() as $category): ?>
<?= $category ?>
<?php endforeach ?>
</p>
</figcaption>
</div>
</figure>
</li>
<div class="featured-text ml-16 mr-10 mt-24">
<?= $featured->text() ?>
<a href=" <?= $featured->url() ?> ">
<button class="featured-button mt-8">View Project <i class="ml-4" data-feather="arrow-up-right"></i> </button>
</a>
</div>
<?php endforeach ?>
</div>