Is it possible to add nodes to the front of the queue rather than the back? I see the "Reverse in admin view" option displays the queue the other way round, but the positions don't change do they? Ie, a node just added to a queue of 20 nodes will still have position no.21. Is that right?

What I'm trying to do is create 3 views that display nodes from the same queue and filter using the Nodequeue position filter:
View1: the 4 most recently added stories (which would ideally be at the front of the queue)
View2: the 5-10 most recently added stories
View3: the next 10 stories in the queue (but not necessarily all)

Is this possible?

Comments

merlinofchaos’s picture

Status: Active » Fixed

You can reverse the views as well as the admin view and get what you want.

merlinofchaos’s picture

You don't need to set your view up by positions, you can use $offset = X; in the PHP arg code to get a similar result and not care what the actual positions are.

freatida’s picture

Thanks for replying.
I don't think I explained very well.
The views should display the stories according to when they were added to the queue (not created generally). So View1 would display the 4 articles most recently added to the nodequeue, etc. Is this doable without the Position filter?
The total number of nodes in the queue is undetermined, so I could only offset from the front of the queue, not the back.
I also thought about using positions so the site admin can also re-order the queue manually to control which nodes go in which view that way if needed.

Sorry if I'm being slow here, thanks for your time...

merlinofchaos’s picture

Trust me, try what I said, it works; using $offset you do not need to know positions. It only knows 'end of the queue' that way, and which end is dependent upon which direction you are sorting.

When I implemented this i worked it out and it is possible to do everything.

freatida’s picture

Yes, you're right. It works. Thanks for your help.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

merilainen’s picture

I'm not reopening this because it's such an old issue, but using this method Views gives me duplicate items and then the offset doesn't work.

In general it would be better to have an option to add to the beginning or end of the queue instead of the very confusing reverse admin view. Then the Nodequeue: Position filter would be actually useful in Views.

nikolas.tatianenko’s picture

Issue summary: View changes

Hi,
You could set queue item to the first place by implementing hook nodequeue_add in your module

Here is the example.
/**
* Implements hook_nodequeue_add().
*/
function MODULENAME_nodequeue_add($sqid,$nid) {
// Update position of all items in the queue.
db_query("Update {nodequeue_nodes} SET position = position + 1 WHERE sqid = :sqid", array(':sqid' => $sqid));
// Set specific queue item to the first place.
db_query("Update {nodequeue_nodes} SET position = 1 WHERE sqid = :sqid and nid = :nid", array(':sqid' => $sqid,':nid'=>$nid));
}