olafgleba Posted 2 hours ago Posted 2 hours ago Hi, hm, i have the faint idea i did it sometime ago, but can't remember now i am afraid: I have a page with only one field of type 'file'. Do i have the ability to change the sorting of those files within the backend view? Thx in advance, Olaf
virtualgadjo Posted 2 hours ago Posted 2 hours ago Hi, not sure i really unsderstand your question but if it actually is can you sort/reorder files in the backend, the answer is yes, catching an element in the list by the bar containing its name you can move it to the position you want in the list just in case have a nice day
olafgleba Posted 2 hours ago Author Posted 2 hours ago Hi @virtualgadjo, thx, yes, drag and drop is possible. I meant something like sorting the files alphabetically for example. Or by name etc. Just like you do it template based in the page tree. have a nice day too 😉
virtualgadjo Posted 2 hours ago Posted 2 hours ago Hi again @olafgleba i thought i was going for something "a litlle" too simple knowing what you want to do, tha answer is still yes but it's a little more technical though easy, the solution i imagine would be a simple hook, same king of trick as when you want to sort the elements of a repeater, hope i'm closer to what you're looking for 🙂 have a nice day 1
olafgleba Posted 2 hours ago Author Posted 2 hours ago @virtualgadjo, thx for the helpfull answers. Yes, it all leads to do it with a hook. I just wondered i maybe missed something i overlook. So, hook, here we go... Cheers, Olaf
virtualgadjo Posted 2 hours ago Posted 2 hours ago @olafgleba i'm afraid you didn't missed anything, there is no sorting options for files and/or images (same king of things) except from using your mouse 🙂 well something llike this in your ready.php file should do the trick (sorting happens when you save the page) $this->addHookAfter('FieldtypeFile::wakeupValue', function($event) { $field = $event->arguments('field'); // being a frenchie my field is called "fichiers" // change this to yours 🙂 if($field->name !== 'fichiers') return; $pa = $event->return; $pa->sort("name"); $event->return = $pa; }); have a nice day 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now