hooks for add/remove
yched - January 21, 2008 - 12:09
| Project: | Nodequeue |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
It would be useful to have a hook fired when nodes are added / removed from queues.

#1
This should be pretty easy. Patches welcome! =)
#2
+1
#3
I am also needing a hook after a node is added/removed from a queue. Here is a quick patch I created with those hooks. Please review and feedback is appreciated. This is rolled against 5.x-2.2 branch.
#4
Bumping to 6.x. This would be a good feature.
#5
Thanks for the patch!
This looks good but the hook definitions should follow the naming convention nodequeue_api_...
#6
I rerolled it with the naming convention suggested.
#7
Updating status. I hope to test this soon.
#8
Sorry about the delay in reviewing this. I was hoping to get it into the upcoming release, but it currently applies by putting the new code inside of the comments of an existing function definition :-&. Could you reroll with the diff -up option? This is why -up is listed as a best practice for creating patches ;)
#9
@ezra-g
Here is a re-roll with -up option. The patch is currently for the D5 branch. Let me know if you want a roll for the D6 branch as well.
#10
@ezra-g, one more re-roll. I realized my local copy of nodequeue was not the D5 dev branch. This re-roll uses the D5 dev branch.
#11
May i suggest this be one hook not two. hook_nodequeue_api($op, $subqueue, $nid). Where $op would be 'add' or 'remove'. Also, no need for the for loops. just do module_invoke_all('nodequeue_api', 'add', $subqueue, $nid)
#12
I agree with Scott, using a single hook similar to how hook_nodeapi() works would prevent the API from becoming too big and hopefully help in making this more extensible in the future (A quick idea off the top of my head - add another hook call with $op = "pre add" so that other modules can allow or disallow adding a node to a subqueue)
#13
points taken....I'll reroll with those suggestions.
#14
Keep in mind with Drupal 7 we are eliminating the all-encompassing hook_something_api($op) type hooks in favor of splitting them out. Maybe we should keep the hook separate and make it easier to upgrade modules to Drupal 7?
#15
Here's another attempt at a patch.
#16
Marking as needs review.
#17
Don't think hook_nodequeue_swap would be used at all, but I can see why add/remove would be nice. Here's an updated patch with some more documentation.
#18
In our systems we use a custom type of caching that stores the output of pages. The swap hook is used to notify when delta's have changed so that we can rebuild that part of the cache. I think it's a pretty important item to have in place.
#19
Ah, then making sure you get notified when the position has switches is important ;-) .
#20
This patch builds on what was done in #17 by adding hook_nodequeue_swap back in with documentation
#21
This is committed, minus the nodequeue.api.php. We already have a readme file and a documentation page on drupal.org. @Cyberswat: Could you update the documentation page with these new functions please :)?
Thanks!
#22
Thanks for the work on this, am looking forward to the next version :)
#23
@ezra-g: I added a Nodequeue API section to the documentation page. I seriously suck at documentation so feel free to revise :) Thanks for getting these hooks committed.
#24
+1 for nodequeue.api.php. It's the new standard for documenting hooks.
#25
Automatically closed -- issue fixed for 2 weeks with no activity.