Move across multiple pages
mr.andrey - August 7, 2009 - 18:47
| Project: | DraggableViews |
| Version: | 6.x-3.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hello,
I just set up Draggable Views to use with Flag Weight module to create a Netflix-like Queue where users can add videos to their Queue and reorder it as they want. One cool feature that Netflix has is "move to top of queue". This gives users the ability to move something from page 5 of their queue to the top of page 1.
Is this possible to implement with Draggable Views?
Is there another way to move items between pages?
Thanks,
Andrey.

#1
All you have to do is setting the order value to -1. This will cause draggableviews to rebuild the structure (because -1 is an illegal order value). While rebuilding the structure all nodes will be sorted according to their current order values (even if they're illegal) before they become renumbered. So your node with order value -1 will appear on top.
If you used native handler you would have to set the order value of the certain node manually:
<?phpdb_query('UPDATE {draggableviews_structure} SET value=0 WHERE vid=%d AND nid=%d AND delta=0', $view_id, $node_id); // delta=0 means that this is an order value.
?>
Setting the flag_weights value works similar..?
Greetings,
sevi
#2
Ah, very interesting. Thanks for the reply.
So after it gets resorted the -1 changes into a valid number (0,1, etc), so the next time I set the order value to -1, it will just go to the top?
Is there a way to have this whole operation be done in ajax without reloading the page? Change the order value, refresh the page, and stay on whatever page number in the views I was on?
Thanks,
Andrey.
UPDATE: Just tested this for flag weights and it works. If I set the flag weight in `flag_content` to -1, it reorders the structure as you said. -1 becomes 0 and the table gets reordered.
So to modify your query for flag weights:
<?phpdb_query('UPDATE {flag_content} SET weight="-1" WHERE uid=%d AND content_id=%d AND content_type="node" ', $user_id, $node_id);
?>
Depending on where that query goes, I can also use the `fcid` column.
#3
I created a new module for stuff like this.
Please re-create this issue at DraggableViews Navigator.
Greetings,
sevi