Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Treeleft and Treeright

Hi Guys,

I wanted to insert Category table from an XLS as a Source. I have the categories, but I could no find any information how can I set the fields entries for column treeleft and treeright.
Would you please tell me the algorithm?

For example, the main category:
CategoryID = -1
Treeleft = 1
Treeright = 6

CategoryID = 1
Treeleft = 4
Treeright = 5

CategoryID = 2
Treeleft = 2
Treeright = 3

So, if I want to insert the next one, I have to set Treeright = 8 for CategoryID = -1 and create new one

CategoryID = 3
Treeleft = 6
Treeright = 7

But it seems, the numbers are the highest on the CategoryID lowest...
THank you, Madi

Comments

  • x00x00 MVP
    edited May 2017

    it is always best to use the model rather then directly interact with the database especially due to the other relationships involved. Just not a good idea. There is also an API you can use.

    The algorithm is called "nested set", you can't just add rows it is quite complicated, let vanilla handle it.

    grep is your friend.

  • Hi x00 this is a fresh and clean install, so there is nothing to relationship with categories yet.
    Can you tell me more about the mentioned API?
    Thx

Sign In or Register to comment.