I’m trying to sort files in a section by upload date so that their order doesn’t change when the metadata changes.
Here’s what I’m trying to do:
<?php
Kirby::plugin('test/file-methods', [
'fileMethods' => [
'modifiedDate' => function($format = null) {
return Str::date(F::modified($this->root()), $format);
},
],
'filesMethods' => [
'sortByUploadedDate' => function($direction = 'asc') {
return $this->sortBy(fn ($file) => $file->modifiedDate(), $direction);
}
]
]);
Blueprint file:
sections:
files:
headline: Files
type: files
layout: cards
size: medium
limit: 100
sortBy: sortByUploadedDate desc
info: "<small>Upload {{ file.modifiedDate('d.m.Y H:i') }}</small><br><small>Modified {{ file.modified('d.m.Y H:i') }}</small><br>{{ file.niceSize }}"
But the files in the panel aren’t sorted by upload date. I’m asking for help from the community. Thanks in advance!