Page 1 of 1

Incremental Update: Re-ordering Menu Structure

Posted: Wed Feb 22, 2006 1:29 pm
by kendall
hello,

im building a dynamic menu structure in which has submenus and want to be able to effeciently impliment a re-ordering system based on user selection.
i have the following menu structure

Code: Select all

ID | menu | group | parent | order
43981 | Client Success | Success  |0  |1  
7000 | Services |  Services  |0  |  2
4000|  About Us  | About  | 0 | 3 
4001  |  Who We Are  |  About  | 4000 |4 
4002  |  Strategic Partners | About  |4000  |5  
4003  |  Contact Us  | About  | 4000 |6
Now lets use an e.g. to explain what i want to accomplish...
lets say i want to move 4002 from position 5 to 4
pretty easy
  • First i update the menus between 4 and 5
  • Then i update 4002 to 4
but lets say i want to move menu 4000 to 1
  • First i update the menus between 2 and 3
  • Then i update 4000 to 1
  • Then update menus to 1+(i++) who is child of 4000
So...I run into the following problems
Updating menus position based on thier submenus if any
How can i generate the (i++) on each row update
Any suggestions of improving this theory?

Kendall

Posted: Wed Feb 22, 2006 5:35 pm
by Christopher
Since there are only a small number of items, it might make sense to load them all, make the changes and the update them all. That way the whole list is atomic. I doubt it will be updated often.

Posted: Thu Feb 23, 2006 5:17 am
by CoderGoblin
This sitepoint article may be of interest....

Storing Hierarchical Data in a Database

Posted: Thu Feb 23, 2006 9:09 am
by kendall
CodeGoblin,

Yeah i knew about that. I was trying it out for a while and found the updating part a bit tedious so i opted for the solution i was trying out now...apparantly i didnt realise that my method is even more tedious and cumbersome. oh well back to the drawing board