Hello, I can’t manage to sort my files according to their position in the layout in the panel. It keeps getting back at their name sorting.
Many thanks for the help,
best
<div class="gallery">
<?php foreach ($page->files() as $file): ?>
<?php $file->sortBy('sort') ?>
<?php if($file->type() == 'image'): ?>
<div><figure><img src="<?= $file->url() ?>" alt=""></figure></div>
<?php endif ?>
<?php if($file->type() == 'video'): ?>
<video width="auto" height="fit-content" controls controlslist="nodownload, noremoteplayback" disablePictureInPicture
src="<?= $file->url() ?>">
</video>
<?php endif ?>
<?php endforeach ?>
layout:
type: fields
fields:
Gallery:
type: layout
layouts:
- "1/3, 1/3, 1/3"
fieldsets:
- image
- video