Hello.
I would like to build a “cover image slider”. So I need to pick not just one but multiple images as cover. Is there any concept to achieve that with php or a cool kirby functions?
I tried this to implement some ideas from this: Filter to exclude files that contain specific string in their name
And i came up with this not working code:
<div class="cover_show">
<?php foreach ($cat as $item): ?>
<a class="image_container" href="<?= $item->url() ?>">
<?=
$files = $item->files()->filterBy('filename', '*=', 'cover')
?>
<?php foreach ($files as $cover): ?>
<?= $cover->cover()?>
<?php endforeach; ?>
</a>
<?php endforeach; ?>
</div>
cover function like this :
public function cover()
{
return $this->content()->get('cover')->toFile() ?? $this->image();
}
It looks like the whole foreach
part is doing nothing – the output is only the string of the images with cover in its filename.
Does anyone have an idea?