My site uses this structure in place of “projects”:
home/artworks/artwork1
home/artworks/artwork2
etc
I naively assumed I could replace “project” and “projects” string in the showcase snippet but this breaks the page and throws up an error. I have templates in place for artworks and artwork, which worked until I inserted my edited code.
The reason I need to do this is I need to categorize my portfolio at the top level, instead of having everything lumped into one.
<?php
$projects = page('artworks')->children()->visible();
/*
The $limit parameter can be passed to this snippet to
display only a specified amount of projects:
<?php snippet('showcase', ['limit' => 3]) ?>
Learn more about snippets and parameters at:
https://getkirby.com/docs/templates/snippets
*/
if(isset($limit)) $artworks = $artworks->limit($limit);
?>
<ul class="showcase grid gutter-1">
<?php foreach($artworks as $artwork): ?>
<li class="showcase-item column">
<a href="<?= $project->url() ?>" class="showcase-link">
<?php if($image = $artwork->images()->sortBy('sort', 'asc')->first()): $thumb = $image->crop(600, 600); ?>
<img src="<?= $thumb->url() ?>" alt="Thumbnail for <?= $artwork->title()->html() ?>" class="showcase-image" />
<?php endif ?>
<div class="showcase-caption">
<h3 class="showcase-title"><?= $artwork->title()->html() ?></h3>
</div>
</a>
</li>
<?php endforeach ?>
Yes, there’s images in there. They’re displayed fine on pages using my artwork template. However, nothing is rendered after the “artworks php” on my artworks page: