I am using "Comments" as a note option. I want to let users add the same comment to multiple nodes with the Views Bulk Operations (VBO) module.
How do I get the "Add Comment Form" in VBO to achieve this?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI am using "Comments" as a note option. I want to let users add the same comment to multiple nodes with the Views Bulk Operations (VBO) module.
How do I get the "Add Comment Form" in VBO to achieve this?
Use the Rules module to create a Rules Component, which includes whatever Rules Conditions you might need (if any), and with a Rules Action to create an entity, of type "Comment", whereas you specify some relevant parameters for that Rules Component, such as:
Below is an example of a Rules Action that creates a comment (in Rules export format, use the Rules UI to import it in your own site):
{ "rules_add_a_comment_to_a_node" : {
"LABEL" : "Add a comment to a node",
"PLUGIN" : "rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : {
"comment_node" : { "label" : "Node to add comment", "type" : "node" },
"comment_body" : { "label" : "Comment body", "type" : "text_formatted" },
"comment_subject" : { "label" : "Comment subject", "type" : "text" }
},
"IF" : [
{ "user_has_role" : {
"account" : [ "site:current-user" ],
"roles" : { "value" : { "2" : "2" } }
}
}
],
"DO" : [
{ "entity_create" : {
"USING" : {
"type" : "comment",
"param_subject" : [ "comment-subject" ],
"param_node" : [ "comment-node" ],
"param_author" : [ "site:current-user" ],
"param_comment_body" : [ "comment-body" ]
},
"PROVIDE" : { "entity_created" : { "comment_created" : "Created comment" } }
}
}
]
}
}
Create a view of the nodes to which some comment is to be added. Then transform that view into a view that uses Views Bulk Operations, and use the technique documented in "How to use Rules to create a custom bulk operation for a VBO view?". In doing so, you'll then be able to use the Rules Component from Step 1.
PS: this answer is for D7 ...