// fetch the child page into a variable and make sure it exists, then also check if it has images
if (($p = $page->children()->find('project-01')) && $p->hasImages()) : ?>
<?php foreach($p->images() as $file): ?>
<img src="<?= $file->url() ?>" alt="<?= $file->alt() ?>">
<figcaption><?= $file->caption() ?></figcaption>
<?php endforeach ?>
<?php endif ?>
But in the title it says you want to fetch images from multiple subfolders, here we have only one? So I have a feeling there is some context missing…
But it doesn’t work. I went back to adding the swiper-container element. How could i change the “project-01” into something more automatic, like, following the order of the folders that are there? I’m not sure if i’m being clear… Basically i have this folder structure with images inside of each folder:
This cannot work, because $p is not known inside the snippet, you would have to pass it to the snippet snippet('gallery', ['p' => $p]). But for you use case, what I posted above would be more useful anyway.
Oh, sorry for the code screenshot! Yeah, i’m pulling the text content from home.txt, where i have the whole content, i have fields like so: project01, project02, project03, etc.
Rendered, i’d have text and the sliding gallery after, for each project.
It’s a single page site, so my first thought was having all content in one file, the home.txt. But now with the images organized in folders, it makes more sense to have a txt content file for each project. I tested it this way and it works. I do lose the ability to edit everything in one file, but now it’s more organized.