This topic is 1 of the banes of my existence. There is little else so annoying and so frustrating as, “How do we Sort it?“. If we’re showing a list of campus courses what is the sort order? Alphabetical? By some hidden serial value? By Content Type? Newest to Oldest? … for any listing of content the sort order is either simple — or completely arbitrary. I run into the issue quite a lot. Sometimes a solution such as a Serial Field suffices, but usually it’s more annoying than that.
Recently I stumbled across the Draggable Views module. It looks like this module is slated for inclusion into Drupal 8 (but I’m uncertain of its final status in D8). The features listed on the project page are:
- Order any type of entity
- Set different order for different set of arguments
- Create one view that sets the order, and create as many views as you like that shows that order
So, this module allows you to create special Views display that can act as the sort order for the same view. This new View can act as the Admin UI used to set the sort for a certain view for site administrators! Nice!
An example of this module for a logged in admin user having been properly configured can look like the following image. The 2 tables at the bottom are the content of the View(s) at the top of the page — when you click-and-drag a row around it’s position is saved and updated in the master public view.
This is an example for the actual Sorting view, the key element is the DraggableView field in this View, this essentially links the hidden NID value in the view as the row weight when sorting.
Lastly, it’s important to consider the performance issues when using this module. Basically we’re using a View to be the sort of another View. A View is not a piece of content — a view is a query. So, when using draggable views you should consider enabling the views Caching under the Advanced tab for the view. There is no need to run the SQL to define the sort order on every page load of the public view. It should be able to be pulled from a cache to help maintain high performance on your website.
Looking for quality web hosting? Look no further than Arvixe Web Hosting!