Hei all!
I am currently working on my photography website and have some issues with a latest view on the startpage: I am trying to get the latest galleries to display one on the startpage. “Date” is a field in gallery.txt inside the galleries-folders.
My structure is as follows (example):
/content
…01-bands
…01-a
…01-bandwithnamea01
…gallery-01
…gallery-02
…band.txt
…02-bandwithnamea02
…gallery-01
…band.txt
…02-b
…01-bandwithnameb01
…gallery-01
…gallery-02
…band.txt
(…etc.)
At the moment, I get the galleries entries displayed as thumbs with links using this code for testing purposes:
<? foreach(page('bands')->children()->visible() as $bandcollection): ?>
<? foreach($bandcollection->children()->visible() as $bandcollection2): ?>
<? foreach($bandcollection2->children()->invisible()->sortBy('date','desc') as $bands): ?>
<div class="column">
<? if($image = $bands->images()->sortBy('sort', 'asc')->first()): ?>
<a href="<?= $bands->url() ?>" title="<?= $bands->title() ?>">
<figure>
<img src="<?= $image->crop(400)->url(); ?>" alt="<?= $image->name() ?>">
<figcaption><?= $bands->title()->html() ?><br><time datetime="<?= $bands->date('c') ?>"><?= $bands->date('d.m.Y') ?></time></figcaption>
</figure>
</a>
<? endif ?>
</div>
<? endforeach ?>
<? endforeach ?>
<? endforeach ?>
The code works and displays the link to the gallery and a thumb from it. It sorts the links within the confines of a folder (e.g. 01-bandwithnamea01) – I instead need to get all galleries sorted by date.
I am not sure if there is a more easier and cleaner method to get the content from my galleries deep down in my structure - I have already looked for a cleaner solution inside Kirby’s documents, but did not find anything suitable.
I am not sure if I have to add all subfolders to an array now (with another foreach-loop).
Probably I have been staring too long on my screen today and I am stuck in a rut.
Any pointers to a better solution are welcome.
Thanks in advance,
Thorvald