Hi, I am trying to add nodes to an entity subqueue using Rules, but my changes actually never get saved. I verified that my events if being fired.
The first action I am using is "Fetch entity by id", and I specify my ID in the when setting it up. This is working, the subqueue gets loaded.
Then I use a custom action, that takes 2 parameters: the subqueue, and the node to be added. Here is the code:
/**
* Add a node to a subqueue
*/
function add_node_to_entityqueue($subqueue, $node){
$subqueue->eq_node[LANGUAGE_NONE][] = array('target_id' => $node->nid);
entityqueue_subqueue_save($subqueue);
}
I can't add some debugging in this function to check that the subqueue and the node are loaded. But for some reason the subqueue is not being saved.
Can you help me with this?
Thanks,
Comments
Comment #1
jojonaloha commentedI think there might be something wrong with your rule or action definition. If you can provide the exports, that might help. Here is the code I have for both that seems to work fine for me.
Exported rule. Note: I have the devel module enabled and am using the debug value action in my rule to see that it is working.
Comment #2
amateescu commentedCleaning up the issue queue :)
Comment #3
kbrinnerI know this issue has been closed, but for those who like me were looking to create a custom action using entityqueue, it appears there are a couple of gotchas here. I found that if I didn't start the callback function with my custom module's name (ie [MYMODULE]) I would just get an error ''Unknown action" after selecting the custom action from the dropdown.
For the above example, I had to rename
add_node_to_entityqueuetodemo_add_node_to_entityqueue.Here's the full code:
Comment #4
jojonaloha commentedFor those interested in Rules integration, we are accepting patches in #2474519: Add support for Rules
Comment #5
glynster commentedI am needing this for a Drupal 8 project. What needs to be adapted so this will be recognized in Rules @kbrinner?
Comment #6
lokeshsn22 commentedCan you please provide the same for Drupal 8. I need tp update the queue progrmatically once after the node is added. Can some one help me out in this.
Comment #7
Pls commentedhttp://cgit.drupalcode.org/auto_entityqueue/tree/auto_entityqueue.module... - this module does the job of automatically adding to queue, and this code is perfect example how you can implement it yourself on Drupal 8.