|  | Posted by Sandman on 11/16/05 17:18 
In article <dlcc0t$5pr$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com>,"Angelos" <angelos@redcatmedia.net> wrote:
 
 > Hello again,
 >
 > I have this dynamic menu and I want to change the order of the menu items...
 > I added a column in the database wich has an integer value for ordering the
 > menuitems.
 > But the only way is by hardcoding them into the database.
 >
 > I would like a way to sort them with drag-and-drop or with up/down arrows.
 >
 > Do you think that except PHP & MYsql I will need Javascript as well ?
 > Any ideas how to do that ?
 
 I do this all the time.
 
 In pseudo code:
 
 $position=0;
 foreach ($menu as $m){
 $position++;
 $uplink = "admin.php?move=$m[id]&to=" ($position-1);
 $downlink = "admin.php?move=$m[id]&to=" ($position+1);
 
 print "(uplink icon) (downlink icon) row data....<br />";
 }
 
 
 Then you update the sortorder field when either link is clicked. Remember to
 update the field that it is moved TO so it is moved down/up respectively.
 
 Of course, if the row is the first or the last, you shouldn't have either a
 uplink or downlink.
 
 Plus, if you have a hierarchical menu (like I do), you need to keep track of
 the position number relative to the current hierarchy leve and send that along
 with the query (i.e. move=12&to=3&mother=23)
 
 
 --
 Sandman[.net]
 [Back to original message] |