SimpleTree Trait

Hi,

I have two models:

Course that can have many Lesson.

I want to be able to order the Lessons inside a Course.

I tried to implement a SimpleTree Trait (I use the example of the Category in october/test/trees demo plugin)

I changed the parent_id for “course_id” but it doesn’t work. I’m probably missing something.

Quick view of the tables:

  1. author_plugin_courses

    id | title | description 
    
  2. author_plugin_lessons

    id | course_id | title | description | sort_order
    

Maybe it’s the wrong way to go. Can’t find many examples on that… if anyone can point out a direction, it would be appreciated !

Thank you.

The teacher should be able to manage the order of the lessons that the students will go through during the course.

image

I could try to implement a custom solution but if there is something out of the box that can apply, it would be better.

Thank you

Hey @apinard

Simple Tree manages basic child-parent relationships. I think you may need the Sortable trait for this…

Hi,

According to the docs, Sortable Trait seems to be useful if you have a simple model (ex: User) and you want to order them AMONG them.

The things is I want to order records related to a parent category (in a relation driven by the relationcontroller).

I found this post : Reorder of records in relation · Issue #3010 · octobercms/october · GitHub

The guy end up doing a custom solution but this is back in 2017. Wondering if a native solution was implemented? Simple Tree was the closest thing that I found (but still not sure how to implement it).

Hi @apinard

Take a look at this

1 Like

Took me 2 minutes looking at that documentation.

Awesome, thank you.