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.
| Comment | File | Size | Author |
|---|---|---|---|
| feature_package_module.txt | 4.67 KB | wonder95 | |
| feature_package_view.txt | 15.09 KB | wonder95 |
Comments
Comment #1
wonder95 commentedGot 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.
If anyone has a better way to do this, feel free to share.
Comment #2
ezra-g commentedThanks 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.
Comment #3
ezra-g commentedAlso, for folks looking to implement a similar feature, there's code at http://drupal.org/node/184319#comment-2241880 that could use some review ;).