Hi everyone.
I’m working with a nested set for my site categories and I’m having trouble figuring out how i will reorder the sets when i need to change ordering.
One of my ideas:
This is a nested set just for this example.
A - open 1 - close - 12
B - open 2 - close - 3
C - open 4 - close - 5
D - open 6 - close - 7
E - open 8 - close - 9
F - open 10 - close - 11
Let’s say i need to change the ordering of E to be after B that means i need to change the opening value of E to 4 and close to 5.
Now i need to add 2 to the other categories opening and closing value, now here is the problem if i run a query that will update the other categories i will have a problem with C because C and E have the same open and close value, so if i query and say update all open and close values + 2 where the value is higher then 5 then C will be skipped.
An idea that i have is to change the opening and closing value of E to outside the biggest closing number (So that will be open 13 - close -14) then change the open and close value of the other categories and once that is done insert E into the original position i need it.
I’m having trouble figuring out if this is the best way to do it, so is anyone have a better way or can point me in the right directions that will be so great.
Best regards.