Posted by wonder95 on December 14, 2009 at 7:02pm
4 followers
| Project: | Views Bulk Operations (VBO) |
| Version: | 6.x-1.x-dev |
| Component: | Actions |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
As part of an installation process, I need to assign an action to an existing Bulk Operations view. What is the best way to do that in code? The action is already created, so it just needs to be assigned to the view.
Thanks.
Comments
#1
Implemented in the latest dev. Call function
views_bulk_operations_add_actions($vid, $actions)with$vid= view name or id, and$actionsis an array of actions, specified either by callback name, by aid (action id as stored in theactionstable), or by action title (as defined in Site configuration > Actions > Manage actions).Please try (12 hours from now) and let me know if that works for you!
#2
No, this isn't working. Here's the relevant code from my .install file:
$function = 'feature_package_add_to_subqueue_action';$type = 'node';
$params = array('qid' => variable_get('feature_package_qid',1));
$desc = 'Add to Feature Package';
$aid = actions_save($function, $type, $params, $desc);
//add action to VBO view
$actions = array($aid);
views_bulk_operations_add_actions('feature_package', $actions);
The action is created okay, and I get the $aid value, but it seems that the view can't be loaded by views_get_view because it can't find the view. After stepping through the views code a bit, it appears to me that s it's because the view is in a feature and isn't saved in the database at this point in the process, since view:load looks for the view in the views_view table.
#3
The short answer to this, according to merlinofchaos, is that at the point in the install process where I am running this, default views aren't available, so there is nothing to attach to. So sorry, I can't tell you if this works yet. I might try to come back to this later and use it in a different context in my module.
#4
As a side note, the current dev version screws up the AJAX, in particular the editing of the Bulk Operations settings in a view. With this installed, I am unable to either change the style of a view display to Bulk Operations or edit style settings for an existing BO style. When I went back to version 6.x-1.8, this problem went away.
#5
Your side issue might be related to #654674: Errors when trying to use latest dev version. You can subscribe there for updates.
#6
Automatically closed -- issue fixed for 2 weeks with no activity.
#7
At the moment it looks like this can only be used on actions, not operations declared using hook_user_operations(). Is this correct or am I missing something?
Would be great to be able to use it for this circumstance as well.
#8
You're right, VBO doesn't do that. I'll add this feature.