3

The Group module is an alternative for Organic Groups. One of the features it offers is that you can assign nodes to a Group.

Question: how to bulk-assign a set of existing nodes to a specific group, using site building techniques only (not programmatically, which appears to be a possible alternative also)?

1 Answer 1

1

Step 1: Create a Rules Component

Have a look at this example of a Rules Component (in Rules export format):

{ "rules_assign_existing_content_to_a_group" : {
    "LABEL" : "Assign existing content to a group",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "TAGS" : [ "group" ],
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "node_to_assign" : { "label" : "Node to be assigned", "type" : "node" },
      "assigned_group" : { "label" : "Assigned group", "type" : "group" }
    },
    "IF" : [
      { "entity_is_of_type" : { "entity" : [ "node-to-assign" ], "type" : "node" } }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "node-to-assign:group" ], "value" : [ "assigned-group" ] } }
    ]
  }
}

This Rules Component will be used in the subsequent step.

Note that I've not added a Rules Condition here about selected content types, that's possibly an extra condition you might want to add also.

If you want, just grab (copy) the exported rule above, and simply import this Rules Component in your own environment.

After you did this, you can navigate to admin/config/workflow/rules/components in your own site, and then use the hyperlink "execute" to qa-test it in your own site. After you use that link, use the button that says Switch to direct input mode. Then you'll be able to enter some Node to be assigned. Use a similar technique to specify the Assigned Group and hit the Execute mode. The node you selected will be assigned to the group you specified.

After you're confident your rule works fine, move on to the next step below.

Step 2: Let VBO to the bulk of the work

This step is pretty easy ... Just create an appropriate view of all your nodes to be processed, and transform it into a Views Bulk Operations view. The clue to what you want VBO to do as an operation is ... you guessed it: Execute the Rules Component from Step 1.

If you're not familiar with how to do so, have a look at the video about Using Rules components with VBO". If you want even more, then also watch the subsequent "Using Rules components with more than one parameter" video.

Attention: to process many nodes at once is quite a challenge (memory requirements, etc). Therefor you might want to also watch the video about "More details about VBO settings" ... Before you are tempted to use VBO for processing them all at once ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.