Closed (fixed)
Project:
Views Bulk Operations (VBO)
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
15 Oct 2008 at 14:28 UTC
Updated:
22 May 2009 at 22:17 UTC
Jump to comment: Most recent file
Comments
Comment #1
infojunkieI suggest writing a node operation. The nice thing about them is that they expect an array of nodes. Your implementation is free to iterate on each or to perform a single action using the whole array.
Comment #2
moshe weitzman commentedI didn't know that. Perfect.
Comment #3
moshe weitzman commentedActually, thats not entirely perfect.
I have to ask add a few form fields in addition to the selection of nodes (what time should the newsletter go out, FROM address, etc.). I had planned to use a configureable action for that, but now it sems that node operation is a better fit.
Whats the best way to add some form fields that get passed to the node operation? I can probably just form alter them in (never tried that on a multi-step form, but I assume it will work fine).
But getting the values of the custom fields is a problem. I see in the code that 'callback arguments' get passed to the node operation but thats not really what I need. i need $form_values. Perhaps you could just add that the end of 'callback arguments'? Any alternative suggestions?
Comment #4
infojunkieThat's a good idea. But I found another problem: the code in VBO 6.x calls the operation repeatedly with a single node, even if it's a node operation. I did this to simplify dealing with Batch API. I'm currently working on making node_operations accept arrays of nids, and I'll add a way to specify node_operations forms, just like actions.
Comment #5
infojunkieOK. So the code for this is committed to the latest dev. You basically need to implement a node_operation, but with a few twists:
* In the array returned by your hook_node_operations(), add an attribute 'configurable' => true.
* Implement [node_operation_callback]_form, _validate and _submit, exactly like you would if you were implementing a configurable action.
* Your form elements will be passed to your node_operation callback, in the second parameter.
* The callback will only be called once with all selected nodes. Note that this will only occur if the Batch API option is *not* chosen.
That's it! Please try it and let me know.
Comment #6
moshe weitzman commentedThanks so much for the quick response. Now the client is "thinking about their editorial workflow" so it may take a me a bit to get back to this.
Comment #7
moshe weitzman commentedNow I'm being a bit specialized ...
What we actually need to list is not nodes but comments. I am looking at populate_operations method but do not see how to create a comment operation. A comment action will not work with the scheme you have nicely setup. Perhaps you want to make a hook_comment_operations in this module()? Why not?
Comment #8
infojunkieBasically, I want to come up with the simplest hack to support your need. Creating hook_comment_operations() would not generalize well to other object types in the future, because I'd modify VBO to support such hooks for every desired type, whereas currently the actions framework can be extended to any object type.
As an alternative, I am thinking of adding an option to the view settings that instructs VBO to call the action once, stuffing the selected nodes/objects into an array that it passes as the first argument. Would that work for you?
Comment #9
moshe weitzman commentedThat would work for me. I would not declare any hooks for the action so it does not appear on the triggers page. I'll test the module right after you say that the code is in HEAD.
Comment #10
infojunkieIt's in HEAD :-)
To use it, just declare an action with new attribute 'aggregate' => TRUE. VBO will call this action with an array of object ids as first parameter. I tested it with nodes only, but it should work for comments... Caveat: custom actions (the ones whose parameters are pre-saved in the database) will not currently work. They will require further hacking.
Comment #11
moshe weitzman commentedThanks. This is working well.
But now I have run into an unforeseen snafu. I switched my View from table style to Bulk operations style and I lost my Views themeing that was in an override of View specific override of views-view-table.tpl.php. It was relatively easy for me to edit that template to do what I want (add two more rows for every item in the View) but I am not willing nor excited about overriding the the theme_table() to do same.
I don't think VBO needs to do anything more to cater to my needs here. Thanks so much for your changes. You may close this issue when you think it is done. I am contemplating how to proceed.
Comment #12
infojunkieTheming is a pain! Sorry I couldn't help you.
Comment #13
infojunkieComment #14
gregglesThis introduced a php notice which I've fixed (along with another php notice and a few whitespace issues).
Comment #15
infojunkieFixed. Thanks for the patch.
Comment #17
nadam commentedIs it possible to make configurable node operations show up as advanced actions on the actions page to make it possible to make new node operations based on a configurable node operation?
Comment #18
infojunkieNo, that's not an option without serious hacking in the action infrastructure.
However, if you're looking for aggregate actions that are configurable, it is now (6.x-1.7) possible to write your own action that has an attribute
aggregate. This action will receive an array of all selected nodes/objects in its$objectargument. If also marked asconfigurable, you should be able to make an advanced action out of it.Comment #19
nadam commentedThanks! Exactly what I needed. Works great!