I have two sections in my Kirby 3 project, ‘projects’ and ‘work’, both containing subpages. I would like to output all images of the two subpages in random order. So far, so good:
Disclaimer: I want to generate a masonry containing all images in random order. When clicking on an image, you get to a slider containing the images of the individual subpage only.
My questions:
How do I link back to the actual subpage within the foreach loop (#linktoproject)?
Is it possible to provide each image with a unique ID, so I can jump to the specific position in the slider? If so, what would be the most elegant soltion?
If I get your right, you want to get the position of an image within its siblings of the same page, right? That would then be:
$item->parent()->images()->indexOf($item);
The important thing to note is that indexOf() is a collection method, so you can’t call it on a single item like the parent page. Instead, you pass the single item, whose position within the collection you want to get, as parameter to the method.
Now, I would like to be able to click on a thumb in the overview section, and get directed to the specific image in the slider:
project-a/slide:3
I’ve tried your suggestion <?= $item->parent()->images()->indexOf($item); ?> but with every re-load of the overview page (which is shuffled), theindexOf(); changes. Hence, I can not jump to the specific position in the slider.
I don’t see why it should change, because the index position of each image in relation to the parent page should always be the same, no matter how much you shuffle your images on the overview page. Or do you shuffle the images in the subpages as well?