Get Node Id and Title From Nodequeue

Last modified: 
Monday, September 14th, 2015

Here is a helper class that demonstrates a method to get all of the node ids and titles from a nodequeue.

Note the signature of nodequeue_load_nodes(). By default, nodequeue sets a limit of 5 items. Setting the fourth argument to 0 disables this limit.

<?php
/**
 * A helper class for working with nodequeues.
 *
 */
class NodequeueHelper {

  /**
   * Returns the nid and titles for all published nodes in a given nodequeue.
   * @param $qid
   * @return array
   */
  static function getNidAndTitle($qid) {
    $referencedNodes = array();
    $nodes = nodequeue_load_nodes($qid, FALSE, 0, 0, TRUE);
    foreach ($nodes as $node) {
      $referencedNodes[] = array(
        'id' => $node->nid,
        'title' => $node->title,
      );
    }
    return $referencedNodes;
  }

}

// Implementation Example
$qid = 12;
$nodes = NodequeueHelper::getNidAndTitle($qid);
?>


The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.