Jump to content

Recommended Posts

Posted

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 

Posted

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

Posted

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 😉

Posted

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

  • Like 1
Posted

@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

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...