It would be useful to have a hook fired when nodes are added / removed from queues.

Comments

merlinofchaos’s picture

This should be pretty easy. Patches welcome! =)

baldwinlouie’s picture

+1

baldwinlouie’s picture

Status: Active » Needs review
StatusFileSize
new1.21 KB

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.

ezra-g’s picture

Version: 5.x-2.x-dev » 7.x-2.x-dev

Bumping to 6.x. This would be a good feature.

ezra-g’s picture

Status: Needs review » Needs work

Thanks for the patch!

This looks good but the hook definitions should follow the naming convention nodequeue_api_...

baldwinlouie’s picture

StatusFileSize
new685 bytes

I rerolled it with the naming convention suggested.

ezra-g’s picture

Status: Needs work » Needs review

Updating status. I hope to test this soon.

ezra-g’s picture

Status: Needs review » Needs work

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 ;)

baldwinlouie’s picture

StatusFileSize
new1.23 KB

@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.

baldwinlouie’s picture

StatusFileSize
new1.3 KB

@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.

Scott Reynolds’s picture

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)

daniboy’s picture

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)

baldwinlouie’s picture

points taken....I'll reroll with those suggestions.

dave reid’s picture

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?

cyberswat’s picture

StatusFileSize
new1.96 KB

Here's another attempt at a patch.

ezra-g’s picture

Status: Needs work » Needs review

Marking as needs review.

robloach’s picture

StatusFileSize
new2.46 KB

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.

cyberswat’s picture

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.

robloach’s picture

Ah, then making sure you get notified when the position has switches is important ;-) .

cyberswat’s picture

StatusFileSize
new3.25 KB

This patch builds on what was done in #17 by adding hook_nodequeue_swap back in with documentation

ezra-g’s picture

Status: Needs review » Fixed

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!

damienmckenna’s picture

Thanks for the work on this, am looking forward to the next version :)

cyberswat’s picture

@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.

dave reid’s picture

+1 for nodequeue.api.php. It's the new standard for documenting hooks.

Status: Fixed » Closed (fixed)

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