I'm working on a module that creates what is called a feature package, which is simply a grouping of content of all types. I'm using subqueues to store the package items (subqueues instead of nodequeues because there will be a lot of packages and we don't need to create a separate view for each one). The module has a small form that contains the package name and description (and eventually a nodereference field for attaching an existing image, once I get that figured out). When it is submitted, it redirects to a page that will contain a select list of all subqueues in the prescribed nodequeue, a view using VBO to add items to a subqueue (action to add an item to a subqueue being written separately), and an embedded subqueue edit form so that the user can modify the position of items in the package.

The questions is, how do I get all of the parameters necessary for the function nodequeue_arrange_subqueue_form function at the point where I'm calling it now:

function nodequeue_arrange_subqueue_form($form_state, $queue, $nodes, $subqueue)

Currently, when it is called in feature_package_admin_page(), I get the following error:

warning: Invalid argument supplied for foreach() in.../sites/all/modules/contrib/nodequeue/nodequeue.module on line 1052.

because it doesn't have an array of $nodes, and the $queue and $subqueue objects. Do I need to do some queries to get all this data and then call the form? Or is there a better way to embed the form?

The module and the associated view are attached.

Thanks.

Comments

wonder95’s picture

Got the form embedded. By backtracking through the code from the form, I figured out that I have to call nodequeue_admin_view($queue, $subqueue), where $queue and $subqueue are loaded objects created with nodequeue_load() and subqueue_load(). Since I have $sqid in my page callback, I got $qid from nodequeue_subqueue table, and then just called nodequeue_load($qid) and subqueue_load($sqid), and passed the returned objects to nodequeue_admin_view.

  //get parent qid for subqueue
  $sql = "SELECT sqid FROM nodequeue_subqueue WHERE sqid = %d";
  $qid = db_result(db_query($sql, $sqid));
  
  // load queue and subqueue objects
  $queue = nodequeue_load($qid);
  $subqueue = subqueue_load($sqid);

  //Return form field that lists all feature packages
  $output .= drupal_get_form('feature_package_admin_select_form',$sqid);

  //embed view with VBO for adding items to package
  $output .= views_embed_view('feature_package','page_1');
  $output .= '<hr />';
  // embed subqueue edit form
  $output .= "<b>Feaure Package Items</b>";
  $output .= nodequeue_admin_view($queue, $subqueue);
  return $output;

If anyone has a better way to do this, feel free to share.

ezra-g’s picture

Status: Active » Fixed

Thanks for taking the time to answer your original question :).

Regarding the code in #1:

$sql = "SELECT sqid FROM nodequeue_subqueue WHERE sqid = %d";
Perhaps this was a typo but it seems unnecessary to SELECT the sqid if you already know it ;).

A single query to get the *qid* from a given subqueue wouldn't be a huge performance hit, but just FYI subqueue_load() calls nodequeue_load_subqueues(), which can get you a cached subqueue object.

It seems like you figured out what you were looking for here, but please re-open if you have any other questions.

ezra-g’s picture

Also, for folks looking to implement a similar feature, there's code at http://drupal.org/node/184319#comment-2241880 that could use some review ;).

Status: Fixed » Closed (fixed)

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