…I want to show these images on the frontend in the order they appear in the panel, so I am using: <?php foreach($page->images()->sortBy('sort', 'asc') as $work): ?>
The problem is that if I add several images to the section, the order they appear in the section is not the order they appear in the frontend UNLESS at least one of the files has been manually dragged in the panel.
Once at least one image is dragged to another position in the files section, then the sorting order is properly reproduced in the frontend, using the foreach code above.
Am I forgetting something, doing something wrong or is this some sort of bug
Am I perhaps misunderstanding this note on the guide?:
Note that the default sorting order of files is according to their order in the file system. To sort files by their manual sorting order, you can use $files->sortBy('sort') , where sort is the field that stores the sorting number if you manually sort files in the Panel.
I remember there is an issue on GitHub. But if you upload new files, they don’t get a sorting number unless they are sorted by drag&drop- So sorting by the sort field will only work as expected if the files all have a sorting number.
…does this code imply that if there is no sort number, files are sorted by filename ? And does that suggest that if I drop some files in the files section, the order they take is by filename ? Well actually that was easy to test and it seems like it.
So if the above code does what I understood is a perfect solution, thank you, I am going to test