Hi
I’m wondering if there is away to pull a specific file number from the count function.
eg. there is a total of 5 files and using a for each function i would love to have the result of:
1 of 5
2 of 5
3 of 5
4 of 5
5 of 5
Thankful for advice!
Hi
I’m wondering if there is away to pull a specific file number from the count function.
eg. there is a total of 5 files and using a for each function i would love to have the result of:
1 of 5
2 of 5
3 of 5
4 of 5
5 of 5
Thankful for advice!
If I get you right, your are looking for the ‘nth()’ method: http://getkirby.com/docs/cheatsheet/files/nth
Hi @texnixe thank you for the reply.
I’m trying out the nth() as you suggested it’s not giving me the result i was hoping for.
I want to return number 1 for the first image and number 2 for the second image somehow
I’m trying to caption a series of images so each images have the total number of images next to the current image number
Best
Ok, then just use a counter variable in your loop:
<?php
$count =1;
foreach($page->images() as $image) {
// whatever goes here ...
echo "this is image no " . $count . " of " . $page->files()->count();
$count++;
}
?>
SOLVED! Thank you @texnixe