home > controller : shuffle slides + déplacer logique depuis template
All checks were successful
Deploy / Deploy to Production (push) Successful in 3s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-06-05 16:35:08 +02:00
parent 06fc040f80
commit 5d6fa47606
6 changed files with 102 additions and 80 deletions

33
site/controllers/home.php Normal file
View file

@ -0,0 +1,33 @@
<?php
return function($site) {
$files = $site->slideshow()->toFiles();
$count = $files->count();
$units = [];
$i = 0;
while ($i < $count) {
$file = $files->nth($i);
$nextFile = $files->nth($i + 1);
$isPortrait = $file->type() === 'image' && $file->orientation() === 'portrait';
$nextIsPortrait = $nextFile && $nextFile->type() === 'image' && $nextFile->orientation() === 'portrait';
if ($isPortrait && $nextIsPortrait) {
$units[] = ['pair' => true, 'a' => $file, 'b' => $nextFile];
$i += 2;
} else {
$units[] = ['pair' => false, 'file' => $file];
$i++;
}
}
if ($site->areSlidesShuffled()->isTrue()) {
shuffle($units);
}
return [
'slides' => $units,
];
};