I’ve seen several sites that allow users to arrange toolbars (changing the order of links and adding or removing).
What’s the best way to do this?
I’d probably do the following:
Create a new numeric db field ‘listorder’ on users table where the order of links is saved in.
Each link represents a number. Something like this would be in a new table for the links:
first link – 1
second link – 2
third link – 3 etc
Default ‘listorder’ would look like: 123
Custom user arranged: 231
To display the html:
Take 231 apart to an array and find the appropriate content for each link from the db (the new links table).
This looks like it would slow the site down quite due to the queries.
Does anyone know a better way to do something like this?
Cookies wouldn’t work. The order has to be permanent and saved on the user’s account.
If you wanted the value to persist throughout cookie clearage..
store the ID in a serialized cell in a table. use ajax to save the data onchange of the ul elements. use JqueryUI to implement drag n drop of toolbar items. use php to serialize and save the order as submitted back into the table.
update: I wouldn’t use serialized specifically, simple semi-colon delimited would suffice..
IE: $link_order = '1;3;2;6;10;13';Use PHP
<?php explode(';',$link_order); ?>If you just need it as a “temporary” thing..
use cookies and jquery onchange. same method as above just dont use php/db
if you need sample code of both, let me know.