How to reorder your Flagged content
Sometimes it is useful to be able to explicitly sort the content items that a user has flagged. For example, a list of flagged recipes might be sorted by the order you wish to prepare them, or a wishlist might need to be sorted by the order you want to purchase the items.
There is a very simple module that adds this functionality to Flag module, called Flag Weights. This module simply adds a new "weight" column to the database table created by the Flag module. The module provides API functions for flagging an item (with an initial weight), and updating the weight of an existing item.
The module also exposes the new column as a field for Views 2, meaning that you can sort/filter based on this weight field.
Update: The module now provides integration with the Draggable Views module, to allow users to reorder their lists by dragging items around a table. This support is only in the -dev versions of each of these modules.
How to Configure Flag Weights + Draggable Views
This demonstration uses the current -dev releases of both Flag Weights and Draggable Views module, and modifies the view provided by Flag module, rather than creating a new View. In your site, you would probably create a new Flag and a new View etc. From a totally empty Drupal 6 installation, add the following modules:
- Flag module 6.x-1.0-beta6 or newer
- Flag Weights module current -dev snapshot
- Draggable Views module current -dev snapshot
- Views and Views UI from Views module 6.x-2.2 or newer
- (for demo only) Devel and Devel Generate from devel module to generate some dummy content
Generate some Story content using Devel Generate module, and then tag a few of them using the "Bookmark this" link beneath each node (first screenshot below). You can view the default view provided by Flags (second screenshot below).
Now, to turn this into a sortable list, go edit the view at admin/build/views/edit/flag_bookmarks (you would normally clone the view, or create a new one - but I am simplifying for the purpose of this demo). Add a Sort Criteria of "Flags: Weight", and also add this to the Fields. See screenshot below.
Now, change the Basic Settings -> Style from "Table" to "Draggable Table". On the settings page (that appears after you make this change), scroll down and click on "Add order field". When the fields appear above the button, change these to "Weight" and "Flag Weights", per screenshot below:
Click "Update default Display" then "Save", then finally 'View "Page"' link at the top-right of the view settings. Voila! A draggable sortable list of Flags, as shown below:
| Attachment | Size |
|---|---|
| Sortable Flags - Flagging.JPG | 168.6 KB |
| Sortable Flags - Default View.JPG | 119.17 KB |
| Sortable Flags - Field and Sort.JPG | 87.33 KB |
| Sortable Flags - Draggable Table Settings.JPG | 11.38 KB |
| Sortable Flags - Result.JPG | 48.33 KB |

In the configuration of the
In the configuration of the draggable table settings, you can add some normal sorting options (example: author).
Any other added Sorting will break the draggable Settings. Just add the the Order Field and nothing other.
This gives me two errors: -
This gives me two errors:
- The first is at http://drupal.org/node/379810
- The second is that it doesn't give me draggable anything. It just gives me dropdown boxes with numbers for weight.
The field "Flags: Weight"
The field "Flags: Weight" must not be the first in the list. I moved it down the list (to show it on the right side of the table_ and the dropdown boxes dissapeared.
This doesn't seem to be
This doesn't seem to be working for me. I have flagged three nodes, and then I view the page created by this view (flag_bookmarks), and I try to change the order, and then I hit save. When the page loads after saving, the items are usually not in the order that I specified. I think I got it to work once by moving all 3 items into a different position, but even that doesn't work consistently.
What's going on?
Here's what I've got:
Flag module, version 6.x-1.1
Flag Weights Module, version 6.x-1.x-dev (that came out on September 29th, 2009)
Draggable Views Module, version 6.x-3.x-dev (that came out on November 1, 2009)
David White
Owner @ Smooth Stone Services
http://www.smoothstoneservices.com
Web Developer @ TechMission
http://www.techmission.org