I would like to add a node to a nodequeue via my php module and I have the following code snippet:

        $queue = nodequeue_load(3);
        $subqueue = nodequeue_load_subqueues_by_queue($queue->qid);
        nodequeue_subqueue_add($queue, &$subqueue, $nid);

When I try to run this, I get: warning: Attempt to increment/decrement property of non-object in nodequeue.module on line 2189.

Can anyone let me know the proper way to do this? Thanks in advance.

Comments

merlinofchaos’s picture

Status: Active » Fixed

Note that nodequeue_load_subqueues_by_queue() is plural. It's loading an array of subqueues. You either need to get the sqid you want to load a particular subqueue, or use something like current() and get the first subqueue of the array.

arcane’s picture

Thanks I was able to print out the value of $subqueue above and got:

Array
(
    [3] => stdClass Object
        (
            [sqid] => 3
            [qid] => 3
            [reference] => 3
            [title] => Now_Playing
            [count] => 1
        )

)


so my corrected and working version is:

        $queue = nodequeue_load(3);
        $subqueue = nodequeue_load_subqueues_by_queue($queue->qid);
        nodequeue_subqueue_add($queue, &$subqueue[3], $nid); 


Status: Fixed » Closed (fixed)

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