Skip to content
Advertisement

RainLab Plugin Builder issues with reordering

I’m trying to use the RainLab Plugin Builder and I’m having an issue when trying to reorder a series of inputted information.

At first, I was getting an error of…

“The model must implement the NestedTree or Sortable Trait.”

So I looked at October CMS documentation for reordering and added use OctoberRainDatabaseTraitsSortable; to the plugin model. Now I’m getting the error of…

“Unknown column ‘sort_order’ in ‘order clause’ (SQL: select * from jcbbuller_projects_ order by sort_order asc)”

Is this because I didn’t implement the sortable model trait until after I had inputted information into the fields? I have three test items pushed to this plugin’s database so far, just to test out the reordering function.

Advertisement

Answer

Your table is missing sort_order column.

Please read this manual : https://octobercms.com/docs/database/traits#sortable

from plugin builder just add sort_order column and default it to 0. in migration file it should look like below code for sort_order column.

$table->integer('sort_order')->default(0);

if any doubt please comment.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement