Hello,
I want to start off by thanking all of you in advance for reading this and trying to help me out. Please confirm that I have posted this in the correct place as this is the first issue I've posted. This I'm guessing is related to the "add entity to group" action which is why I've put it here.
My goal is to use Rules to add a 'default' vocabulary to each group that is created. I'm certainly not an expert with Rules but imagine this should be pretty simple? The research I've done in this issue queue and in general hasn't provided any solution even though one seems to be what I would need: #512488: when an og is created automatically create an og vocabulary for it with the same name (see post #4). As described in #8 I have left the variables as default.
What I have assumed is correct is the following:
- Event: After Saving New Content
- Condition: Content is of type (Parameter: Content: [node], Content types: Partner)
- Action 1: Create a new entity (Parameter: Entity type: Taxonomy vocabulary, Name: Buildings, Machine name: buildings
Provides variables: Created entity (entity_created)) I have attempted using the "Add a variable" action as well with no luck. - Action 2: Add entity to group
Action 2 is where the problem lies as far as I can tell. The entity data selector only provides entity-created:. My limited understanding is that Rules is looking for data that isn't available for some reason - but I don't know what else it is expecting or why. Of course, removing this colon results in "The data type of the configured argument does not match the parameter's entity requirement." The group data selector is set to node.
If any other information would be helpful to you please don't hesitate to ask. Thank you!
Comments
Comment #1
acrollet commentedI was trying to do this as well, and could not find any incantation to persuade rules to do this. So, I created a rule action for adding a new OG vocab to a group that meets the use case suggested by OP.
Comment #2
tdwhite commentedWorks beautifully! Thanks for your help. I think if there's the ability to add terms to that vocabulary with Rules then this should certainly be committed.
Comment #3
amitaibuThanks, but the rule action should be against OG 2.x
Comment #4
acrollet commentedsetting status - really the rule should have a way to affect the widget options too, but I don't have time work on adding that...
Comment #5
tdwhite commented@Amitaibu I patched with git and am running OG 2.x. No issues from what I could tell - perhaps I misunderstand. :)
Comment #6
amitaibuOk, sorry thought it was against 1.x. Back to needs review.
Comment #7
skyredwang#1 patch works
Comment #8
aleck_wi commentedfor me too.
thanks
Comment #9
wastrilith2k commentedHas anyone figured out how to set the status to Enabled?
Comment #10
wastrilith2k commentedI had to hack the actual og_vocab module to do this as I couldn't determine how to override $og_vocab->is_new.
My issue now is that whenever I create a new og node, it displays EVERY vocabulary on the screen. It seems like it's adding the Entity Reference to OG_vocabulary back to the content type every time I save. I've deleted it from the content type itself as well as from the admin/config/group/fields screen.
Comment #11
wastrilith2k commentedNevermind, it was how I was setting the status to 1 that was causing an issue. I removed that from this patch and just hard coded the default value of status to enabled and that seems to be working. I don't anticipate disabling it so I won't work on a work-around at this point.
Update:
Nevermind, it still shows any OG Vocabularies when I use the rule to create them. It also automatically adds the OG Vocabularies widget to the group content type.
--James
Comment #12
nwom commentedThanks so much for the patch. I'm currently testing it out now. Would it be possible to also include a rule to automatically delete the vocab and all terms when the OG gets deleted?
I'm currently using https://drupal.org/project/OG-Delete to delete all associated nodes already.
Thanks in advanced.
Comment #13
acrollet commentedNWOM: let's try and get this patch reviewed and in on its own merits, and deal with any other rules as separate feature requests.
Comment #14
kolier commentedDo you think it should separate the Name/Machine Name in the action, not just automatically generate the machine name?
Comment #15
solesum commented#1 patch worked for me
Comment #16
solesum commentedWould be extra awesome if this action also provided a variable for the created vocab too!!
Comment #17
gaëlgPatch #1 will associate a vocabulary to the group but the use of this vocabulary on group content editing will require manual enabling.
Correct if I'm wrong, but unless in the specific case of nested groups, this is useless:
The OG vocabulary entity reference field should be associated to the group type but to the group content type.
What about adding a parameter to the rule to define the entity type/bundle that should use OG vocabulary?
Something like this in hook_rules_action_info :
and this code instead of the previously quoted code:
and this function as options callback:
PS: I don't provide a patch because providing the entire .rules.inc file as a patch would not highlight the change, and I'm not very comfortable with patches of patches.
Comment #18
gaëlgComment #19
realityloop commentedPath with GaëlG's suggestions attached
Comment #20
realityloop commentedThere was an error in GaëlG's logic, fixed in attached patch
Comment #21
realityloop commentedAdded ability to configure widget settings
Comment #22
zoraxit is possible to have a widget for adding terms in node-form?
I add your rule when the group is created, but the user can't not add term whatever the widget.
i tested "Autocomplete term widget" "hierarchical select", and "entity reference tree".