At the moment it is possible to add nodes to a nodequeue programmatically, but it requires the developer to understand the concept of subqueues, which might seem daunting to some.

Could we add a simple function which allows developers to do exactly what can be achieved on the GUI at admin/structure/nodequeue/%, something like this:

  /**
   * Add a node to a nodequeue.
   *
   * @param $queue_name
   *   A machine-readable name of the nodequeue.
   * @param $nid
   *   The nid of the node to add.
   */
  function nodequeue_add_node_to_queue($queue_name, $nid) {
    $queue = nodequeue_load_queue_by_name($queue_name);
    $subqueues = nodequeue_load_subqueues_by_queue($queue->qid);
    foreach ($subqueues as $subqueue) {
      nodequeue_subqueue_add($queue, $subqueue, $nid);
    }
  }

A related, more ambitious issue is #373174: Export and import capability for nodequeue .

Comments

  • fizk committed b911af3 on 7.x-2.x
    Issue #2418851: Allow adding a node to a nodequeue programmatically
    
fizk’s picture

Status: Active » Fixed

Great idea :) I'm always creating this kind of custom function when working with nodequeue. Might as well add it to the project ;)

fizk’s picture

I've renamed the function nodequeue_queue_add().

Status: Fixed » Closed (fixed)

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