This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi, I am trying to setup the reorder controller so that i can order how "Projects" are displayed in on the front end but I cannot seem to get it working.
I've tried to follow the documentation but it doesn't seem to be working.
In my Project Model I have replaced: use \October\Rain\Database\Traits\Validation; with use \October\Rain\Database\Traits\Sortable;
Then in my Projects Controller I have added 'Backend\Behaviors\ReorderController' to the $implement and also created the $reorderConfig.
Then in my Projects Controller subfolder I have created the config_reorder.yaml and the reorder.htm.
Can someone tell me what i'm missing? BTW i'm using the Builder plugin.
Thanks in advance Chris
Last updated
You need to make an
orderBy('sort_order', ASC|DESC);
in your query for frontend listing.
Sorry what i meant is that i cannot get the reorder page to display in the backend so i cant reorder my projects.
You don't have to replace the Validation
trait with the Sortable
trait. They can coexist.
What exactly is missing? If you setup your controller like this it should work, however, you might not see it working. Either because you have a session value for a custom column sort-order, or because you do not have your list toolbar partial update to create a link to the reorder page. The reorder controller is a separate action to the controller. It won't show up anywhere in your list part, but is intended to be used separately. Thus you'll need a button to link to it. Check the rainlab/blog/controllers/categories/_list_toolbar.htm
partial for the updated list toolbar content.
Thanks thats really helped, I've now been able to get the re-order button to display in the toolbar and link to the re-order view.
Im now having some issues with the order saving. If i re-order the projects and refresh the page it renders the old order. Do i need to add a "order" field to the database? Or am i missing something else.
To make things easier i've uploaded my code to Github: https://github.com/c-andrews/octobercms_projects_plugin
Thanks again for the help
Hi,
All your columns are sortable. Next problem I can't find any sort_order column in your migrations. At the end you have to order your list
Crazymodder said:
You need to make an
orderBy('sort_order', ASC|DESC);
in your query for frontend listing.
Hi, sorry i've tried to figure out where i put that but i am completely lost. I've changed the number of sortable columns so its just sort_order which is sortable.
Thanks for your help
Did you implement the sortable trait in your model and add the field sort_order to your migration?
Yes i'm using the following at the top of my Project Model: use \October\Rain\Database\Traits\Validation; use \October\Rain\Database\Traits\Sortable;
and i've got a field in the DB called sort_order
Hi, no my sort_order was all 0's for some reason so i've now changed it to 1,2,3, etc and its now working. Thank you for your help. It was becoming quite frustrating.
Last updated
I think the reason is that you missed somethink to implement for reorder functionality. Maybe you check this plugin:
http://octobercms.com/plugin/benfreke-menumanager
There you can see how reorder was implemented.
Any update on this? I have exactly the same problem, and the menumanager plugin uses NestedTree, which is different...
I got the same problem. And just as chris15853 did, I changed the zero's in the databasefields to numbers,(1,2,3 etc) and after that all was working. Really weird. Maybe some databasedude knows the anwser...
Last updated
This is a reported bug. If you implement the sortable trait AFTER the records have been entered you must manually set the ordering in the database for existing records. All new records will be fine. Here's some more information on the bug
https://github.com/octobercms/october/issues/1923#issuecomment-208208793
1-18 of 18