views:

32

answers:

2

I'm an admin for a page and I want to give certain users dynamic control of the menubar layout. The ideal would be a page with a list with menu items and arrows pointing up and down with each item and when you click them the item is reordered. I have a pretty basic idea of how I can do it but I would like some suggestions.

The items are stored in MySQL and I only need help figuring out how the items should be ordered or numbered and how to re-order them. This probably needs some javascript trickery and I'm not familiar with JS.

A: 

You could use jQuery UI draggable to reorder them.

As for saving them into MySQL, simply have an order column and save their position there.

Then when retrieving the records, just add ORDER BY 'order' ASC or similar (should be backticks).

alex
Thanks for the help, I looked at the jQuery UI draggable examples and found it to be quite close to what I was looking for. It seems simple, however, I don't quite get how I can track the position of each item and save it when I click the Submit button (of a simple form).
craide
A: 

This is virtually impossible to answer without knowing what constraints there are on the system - What,specifically is it you're having problems with? Is the code for rendering the menus already written? Not practical to change? If so what is the data structure?

You might want to look at PHPLM - it doesn't provide a graphical editor last time I looked - but it is reasonably well written, cross platform and can accomodate a range of data structures.

symcbean
Thanks for the interest. Specifically, I need a way to display the menubar with control of the position, as in top, 2nd, 3rd, bottom, etc, as well as a way to retrieve the position and translate it to the items in the database.
craide