On your CMS back-end, you will need to have a place to store these preferences. If your user account is in the users table, for example, you could add a string column to that table and store the order of the elements in a comma-delimited array notation. Then when you build that page for the user, you would read that back out and use it to order the widgets on the screen as you build their custom view of the page.
So for example, you have user 42, and their record looks like this:
$user->widgets = 'weather,sports,news'
and user 43 looks like this:
$user->widgets = 'news,sports,weather'
To read that back out, you would take the value of the widgets column, split it by comma, and use that to set the order while you are building the page on the server:
foreach(explode(','.$user->widgets) as $widget){
$user->render_widget($widget);
}
Then, to re-set the order, you would need to provide a sortable layout (I don’t recommend having this be the default layout, only when the user has switched into a mode that means she really wants to sort.) Within that layout, you can either set Sortable to work each time the order changes, or call it manually at the end of the sorting operation.
If you’ve given your sortable elements the proper IDs (widget_news, widget_sports, and widget_weather), then Sortable.serialize will generate an array notation like this: sort_me=weather&sort_me=sports&sort_me=news, which your server will take in as an array called sort_me.
If you look at the source of this page: http://scripty.walterdavisstudio.com/sortable/ you’ll see how to set this up, and the ‘save_sort_order.php’ page that it’s calling out to is just this line of code:
print $_POST['id'] . ': ' . implode(',', $_POST['sort_me']);
(It doesn’t actually save anything in this example, in other words.) If you wanted to save the current order, you would just use the result of implode(',', $_POST['sort_me'])
as the value to set in your widgets column, and then use it as I sketched out earlier.
Walter
On Nov 4, 2011, at 4:31 PM, atelier wrote:
On 26 Mar 2011, 2:52 pm, waltd wrote:
…
You can cause this order to persist using a server-side application,
…This is the same mechanism I use here: http://cms.walterdavisstudio.com/admin.php
to maintain the navigation tree. You drag and drop the pages and
folders around, and if you reload the page, you’ll see that the server
has stored the order.
Hi Walter
How could one build that behaviour in? How do you set those cookies?
I am working on a CMS project where members log in on a page with lot of information. If I make the DIV’s draggable, and if they would stay that way, each member could organise the content on his own page in their own way.
much obliged.
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options