Is webhook on custom sort possible?

Hi, all,

I am trying to trigger a webhook after moving around custom sortable entries in a collection. collections.updatecollection and don’t trigger on reordering. Is there any event that does?


Sorry, there is no event, yet.

Have a look here:

You could change it and send a pull request.

I’m not sure about the best logic and naming convention here… I would suggest to use the same logic like the core save function

or to create a new event, e. g.:

    if (is_array($entries) && count($entries)) {

        $this->app->trigger('collections.admin.updateorder.before', [$collection['name'], &$entries]);

        foreach($entries as $entry) {
            $this->app->storage->save("collections/{$_collectionId}", $entry);

        $this->app->trigger('collections.admin.updateorder.after', [$collection['name'], $entries]);

I tried your suggestion and it works and does trigger, however unfortunately it also triggers when all I do is open the collection before doing any more with it. That does seem to me like I might have uncovered a possible bug. I can’t imagine that it’s intentional that update_order gets called simply by displaying the sortable list, right?

I’m sorry, I have to correct myself. My webhook didn’t save correctly and it was still listening for collections.find.before instead of collections.admin.updateorder.before. My bad. The solution actually works beautifully.

I spent some time trying to decipher the code above. I got it working perfectly now!! Thank you. But renamed to collections.customsort…

I really think this should be pushed into the repo. Can I help.

I barely have any use cases where its not needed. If you use web hooks on collections at all than most likely you have to catch the custom sort function.