I have a nodequeue named work_order.

If I am in a page which belongs to this queue, is there a way I can get the next node that will be there in the nodequeue?

I looked at most of their API functions, but I did not find one that does this.

I am using drupal 7

  • Are you talking about the module named Nodequeue or the queue for cron jobs?
    – Paul
    Commented Jul 14, 2014 at 14:36
  • @Paul module named nodequeue Commented Jul 14, 2014 at 16:14

3 Answers 3


Should be something like getting the nid of the current node and then being $nid the node id of the current node and $sqid the queue id:

$pos = nodequeue_queue_position('work_order', $nid);
$nodes = nodequeue_load_nodes($sqid, FALSE, $pos+1, 1, TRUE);

It's untested so maybe you need to tweak the position and so.

  • sorry, but what is $sqid here? Commented Jul 14, 2014 at 16:00
  • It should be the id of your nodequeue, "work_order"
    – pcambra
    Commented Jul 14, 2014 at 16:01
  • I have a valid $nid. In the nodequeue admin section my queue's machine name is work_order. However when I pass both to node_queue_position, I get $pos empty... Commented Jul 14, 2014 at 16:15

My solution is bit different from pcambra's. Actually I implement looking for previous and next node like this:

$pos = (int)nodequeue_get_subqueue_position($sqid, $node->nid);
$node_prev = nodequeue_load_nodes($sqid, FALSE, $pos - 2, 1);
$node_next = nodequeue_load_nodes($sqid, FALSE, $pos, 1);

Note: The previous is $pos-2, not $pos-1. The reason is that the returned position of nodequeue_get_subqueue_position is starting from 1, and the argument of position in nodequeue_load_nodes is from 0! The same reason for the next node.

Finally, the node you got is stored in the returned array. For example you can retrieve its nid like this:

$next_node_nid = $node_next[0]->nid;

I got it working using custom_pagers module.


It actually quite simple once you apply the needed patches as the module is not well maintained.


apply these patches -

https://www.drupal.org/node/1288368#comment-6429832 https://www.drupal.org/node/1346194#comment-5881226

Now, just enable the module, create a new custom pager
pager position : sideblock
pager node list : view >> nodequeue_#

to get the correct nodequeue - admin/structure/nodequeue
just hover over the edit link to get the machine id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.