This is Part 2 of a 2-part series examining two different ways to arbitrarily ordering a View. Part 1 can be found here.
In part 2 of our arbitrary views ordering experiment, we're going to take a look at the Module named Nodequeue. Nodequeue is a great way to put your nodes in any order you want, then reference that ordering in a view as a sort criteria. Afterwards we'll compare the two methods, and examine some of the pros and cons of each.
Once again, this tutorial is written for Drupal 6, but from the recent testing I've done with the dev versions in Drupal 7, I don't imagine they will change all that much.
Step 1 - Modules, Content
We'll use the same D6 install from part 1 with Views and Nodequeue installed.
We'll also use the same content. (User profiles for all the employees here at Fuse)
Step 2 - Configuring the Queue
The next step is to setup our nodequeue by going to admin/content/nodequeue/list and clicking 'add_nodequeue'
We'll give it a name and just for fun, let's give it a limited queue size of 7 (the number of people that work here at Fuse)
The 'Reverse in admin view' checkbox is really just a visual setting. Adding items to a queue is done using a autocomplete text field, followed by clicking 'add item'. When you're adding items to a fixed size queue (like ours) items get popped off as you add new ones once you've passed the limit. This option basically lets you choose whether the items you add get inserted at the bottom of the list (and the ones on the top get popped off - this is the default), or vice versa. You can try it out both ways to see what you prefer, but I find I like it the way it is so I'll leave it unchecked.
The next two text fields (Link "add to queue" text, Link "remove from queue" text) allow you to specify links that will appear when viewing nodes to add or remove it from the nodequeue. This is a great feature and can be very handy, but in our case is not necessary so we'll leave them blank.
Lastly, we'll choose Employee as the only node type to appear in the queue. This will basically just filter out all other node types when you're adding nodes to the queue.
Click 'Submit' and congrats! You've created your first nodequeue.
Step 3 - Adding nodes to the queue
Strangely, you'll need to click 'View' in order to start adding nodes to the queue. 'Edit' will actually take you back to the settings page we just filled out.
Adding nodes is very straightforward. We just start typing the title of the node and it will autocomplete, filtering out any nodes that don't match the type we selected earlier. I've gone ahead and added every Employee to the list, and ordered it. (Once again, the order is random other than Greg at the top and the Yeti and I at the bottom) It looks like this:
Step 4 - "Viewing" your queue
So we've created our nodequeue... but where can we actually go to see our nodes listed in that order? Well the module actually created a view for us!
If you click 'Edit' on that View, you'll see that there are some default settings and a Page and Block view already there. Try going to the path specified in the Page view and you'll see a list of all your nodes in the order you specified earlier. (NOTE: I had to actually save the view before this worked for me.. not sure if that's a bug...) Pretty simple, right!
As easy as it is, it may turn out that you don't want to use this automatically generated view. Maybe you have another view set up already and you just want to add your Employees nodequeue as a display to that one instead. Well there are only two things you need to do to get it to work.
If you examine the displays that were automatically generated by the module, you'll see that there are a few nodequeue specific items. In Relationships there is a "Nodequeue: Queue" item. Click on it and take a look at it's settings.
By requiring this relationship, we will filter out items that don't belong to the queue. And the "Limit to one or more queues" option allows us to select which queue we will be using for the relationship. In this case we only made one queue so there is only one listed, but if you had multiple ones they would be listed as well and you could mix and match different queues. We'll name the relationship "queue". Remember that name because we'll be referencing it in the the Sort Criteria (queue) Nodequeue: Position
The only thing to note here is that the "queue" relationship needs to be referenced for the sorting to work properly. If you have these two items in your view, you can config the rest of it however you want.
Both DraggableViews and Nodequeue are great ways to create an arbitrary custom order for your views. So which one is better? Well if I were judging only on the setup process, I think Nodequeue would win. DraggableViews is great once you get it working, but there are some *undocumented* little quirks in the setup process that require a bit of trial and error to figure out (unless you follow this tutorial of course). Tthe first time I used Nodequeue, I just installed it and got it working without documentation. It's that simple!
However, when it comes to use-case, I think this is one of those "right tool for the job" kind of situations. Nodequeue has a more manual approach to selecting which nodes you want to display. You have to add each node one by one to the list before you can use it. For me, this is the main difference between the two Modules and the deciding factor when choosing between them. Do I want to think about which nodes belong in the list or not? If I want not only the ordering, but also the node selection to be arbitrary, Nodequeue is the one to go with. But if the node selection can be automated with views, DraggableViews is the winner.