Last updated August 9, 2012. Created by joachim on January 10, 2009.
Edited by lyricnz, asb, quicksketch. Log in to edit this page.
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 (Jan 2009) 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. This approach may not work with newer versions of Views/Draggable Views/Flag Weights. 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 |
Comments
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.
It's me, BENNOS.
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
Founder & CEO; Senior Technical Consultant at CENTS
http://developcents.com
Computing, Equipping, Networking, Training & Supporting Nonprofit Organizations Worldwide.
Are you sure you added the
Are you sure you added the flag-weights as the order criteria in the view?
Taniwha Solutions- Drupal Consulting and Implementation. Site design and construction, module development, customization, etc.
Do you have to use the flag
Do you have to use the flag weights module to have draggable bookmarks? I was under the impression that draggableviews does it itself with its 'order' field already?
Update
As of this date you don't need any dev or beta versions.
There is also a user permissions setting for draggableviews (Allow reordering) which seems to be essential for anyone other than admin to be able to use this.
Didn't save flag weights
Didn't save flag weights after reording but worked correctly for flags created after installing these 2 modules.
HTH
Not working with Views 3
For me, this is not working with Views 3 and Flag 6.x-2.0-beta6, together with draggableviews (6.x-3.x-dev) and flag_weights (6.x-1.x-dev).
When configuring the View, a nonsense error message is given ("Anzeige „Seite“: Draggableviews: Sortieren nach Flags: Gewichtung in aufsteigender Reihenfolge."; according to Google translate: "Display" page ": Draggable Views: Sort by flags: weighting in ascending order."), and the View can not be saved.
It does not matter, if Ajax is enabled or disabled, in which column the weight field lives, what "Order Field" is configured or if "Show input fields?" is checked.
This handbook page is either outdated, incoplete, or simply misleading.
Kefk | CineDat | Fotonexus | Encycan | Encymus | Taxidi
Flag Weights has not been
Flag Weights has not been updated in some time, certainly not for Views 3 (which is not the recommended release for D6 anyway)
Taniwha Solutions- Drupal Consulting and Implementation. Site design and construction, module development, customization, etc.