This project is not covered by Drupal’s security advisory policy.
This module effectively extends the functionality of a Views nid argument.
How it works
It provides a new Sort handler that means the View can be sorted in the same
order as the order of nids in the argument.
For example: http://example.com/my-view/9,1,4
If you have correctly configured a Views nid argument your query will be filtered
so that only nodes 9, 1 and 4 will display. By adding an Argument sort (ascending),
the nodes will be also ordered in this way. If you sort descending, then the nodes will be ordered 4, 1 then 9.
You might call this module something like "Node Queue lite" as it provides another way to arbitrarily order nodes in different situations.
You need to add a node argument that allows for multiple nids to be passed into the view. Views Argument Sort is compatible with the format "3,5,4" or "3+5+4".
You then add a "Node: Argument sort" sort to the view. You can choose ascending or descending.
Having created a view, you can add custom menu items to your site which will dictate the sort order of the nodes in that view. This provides a quick and dirty solution for customized sorting pages. Note that it is possible to do the same thing with Node Queue and Draggable Views - and these modules are recommended if you require a user interface for the custom sort options.
Render a View from code
Because you can pass arguments dynamically, this module enables you to ask Views for the output of a view customized with the nodes in the order that you request them on the argument.
// Render nodes programmatically based on the saved nids. For example: // -- In a CCK formatter for a Node Reference field set to multiple values. // -- A Panels pane, where the nids are saved options. // -- A Boxes box, where the nids are saved options. $nids_argument = $this->options['nids']; $output = views_embed_view('my_view', 'default', $nids); return $output;
For the developer, the great thing about the example above is that you don't have to worry about the structure of the output, as this can be controlled through the Views interface. So the output in this example could be teasers, or some fields, or whatever. Once again, there is an API for Node Queue so as soon as your situation gets very complex you should check out that module.
This code is alpha but would get a proper release if the following is resolved. They'll be added as issues to the queue.
- No support yet for the "base_field" of other types of views: user views, file views, and so on.
- MySQL support only. But this will be simple if PostgreSQL supports FIND_IN_SET().
- It will probably break, or just fail, if you don't configure the nid argument properly.
- Maintenance status: Unsupported
- Development status: No further development
- Module categories: Views
- Downloads: 787
- Last modified: December 2, 2014
- This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.