This module provides dragging entities and saving their order.
1) Activate Draggableviews module at admin/modules. 2) Navigate to view edit-page, click on the first link at the Format section and then choose style "table". 3) Click Add button at the "Fields" section and choose field "Content:title", add and apply. 4) Click Add button at the "Fields" section and choose field "Draggableviews: Content", add apply. 5) Click Add button at the "Sort criteria" section and choose field "Draggableviews: Weight", add and choose sort asc, then apply. 6) Save the view and you're done.
In the case of table standard Backdrop tabledrag.js JavaScript is used.
We also support jQuery UI Sortable JavaScript. In order to use it please set
display style HTML List.
By default HTML list is displayed like grid. If you would like it to be
displayed as list override
CSS styles for example in following way:
.draggableviews-processed li.views-row { float: none; width: 100%; margin-left: 0; }
You can create one view to set the order and another view to display the order. Or even create one view with two separate displays. In a view that displays the order there should be no draggableviews field (that makes view sortable), then in the settings of the "draggableviews weight" sorting criteria there will be a selectbox "Display sort as" where you can choose the source view of your weights. This is applicable when you use the Native handler.
1) Activate Draggableviews module at admin/modules. 2) Create a new view
*Things to confirm after you saved your new view.
In the Administrative Views UI, Go back to your View's 'page' display.
Display sort as:
( )
This should be the view and block display you just created. FYI - This is also where you can change it to another view.
Add "Access draggable views" permission to users who should be able to reorder views. If a user does not have this permission they can still see the view, however they will not be able to reorder it.
If you want only want the order view visible to users with "Access draggable views" then set the Access to "Permission: Access draggable views".
When users have the "Access draggable views" and "Use contextual links" permission, they will see a contextual link from the non-reordering view to the ordering view.
Every time we save the order of a view, the current set of arguments are saved with order. You can see this in draggableviews_structure table "args" column. By default when we display order we use all currently passed arguments to a view to "match" arguments in "args" column. This means that we can create a view with contextual filter or exposed filter criteria and save different orders for different sets of arguments.
Using the "Do not use any arguments (use empty arguments)" option will completely ignore passed arguments used in the Arguments handling of Sort criteria Draggable views weight. Be aware that in this case empty arguments set will be used. So you can set order for a view when no arguments passed and then whatever arguments passed, an empty set will be used.
Using the "Prepare arguments with PHP code" option will let you alter arguments before they passed to "matching" with "args" column. For us this means that we can create, for example, several exposed filters, but pass values of only one of values of exposed filters instead of all of them.
Please be aware that in PHP code arguments are passed as an $arguments
variable and you should return an array.
An example:
return array('status' => 1, 'user' => 2); or return $arguments; // $arguments is already an array.
In the $arguments array
For example, say we create two exposed filters: author and node type, but wish
to take into account for ordering
only node type. We would use the following:
unset($arguments['author']); return $arguments;
When using arguments, make sure your ordering view display has the same arguments as the display you want to show the end user. If they do not match, then your ordering will not match.
Using hook_draggableviews_handler_native_arguments_alter(&$arguments, $view, &$form_values)
,
You may remove or change the arguments save to the database, just as the
"Prepare arguments with PHP code" option. See draggavleviews.api.php
for more
details.
Removed Arguments:
If there is view with sort order draggableviews weight and the order is set by another view we show "Order view" contextual link for opening a view that sets the order.
<root>/core/misc/tabledrag.js
.This project is GPL v2 software. See the LICENSE.txt file in this directory for complete text.