Hi all, I am trying to customize the gallery block to make it into a slideshow. The one problem I am running into is adding an image counter into the nav.
I’m getting this error in the front end, any tips?
Block error: "syntax error, unexpected variable "$default", expecting ")"" in block type: "gallery"
One note is that when I apply the counter to a template php file, it doesn’t give this error, seems to be something specific to the block setup?
File path is:
/site/snippets/blocks/gallery.php
<?php
/** @var \Kirby\Cms\Block $block */
$caption = $block->caption();
$images = $block->images();
$total = $block->images()->toFiles()->count()->toInt(int $default = 0)->int();
?>
<div class="image-block">
<?php
$total = $images->count();
foreach ($block->images()->toFiles() as $image): ?>
<div class="mySlides">
<img class="slideshow" src="<?= $image->url() ?>" alt=""></a>
</div>
<?php endforeach ?>
<div class="nav">
<div class="buttons">
<button onclick="plusDivs(-1)">←</button>
<?= $images->indexOf($image) + 1 . "/" . $total;?>
<button onclick="plusDivs(1)">→</button>
</div>
<?php if ($caption->isNotEmpty()): ?>
<?= $caption ?>
<?php endif ?>
</div>
</div>