List Item with individual ID


Im working on a project with the slidesjs image slider.
The slider is nested inside every li of a ul. Since the slidesjs only works with and id but needs to be loaded multiple times inside the li, I don’t know how to proceed.

<section id="buch">
    <?php foreach($data->children()->visible() as $buch): ?>
    <div class="slides" id="slider">
    <?php endforeach ?>

Is there a way to assign a a individual id for slider? I don’t know how to create a id »foreach«

Eager to hear solutions and thank you in advance

Have you tried initializing the slideshows using a class name instead of ids? This should work for most well-written plugins.

If not, you might want to add a counter to the id.

<?php $i = 0; foreach($data->children()->visible() as $buch): ?>
        <div class="slides" id="slider<?php echo $i ?>"></div>
<?php $i++;   endforeach ?>
1 Like

You could also use a page variable, e.g. the UID, then you don’t need the additional variable:

<div class="slides" id="<?php echo $buch->uid() ?>"></div>

Hi twirx,

thank you very much, it worked out for me that way!

That’s the problem if you learn php only by fiddling with kirby and don’t learn it from the ground up…
What a handy function!