Add eval input to "Add a new vocabulary" action
giorgio79 - July 7, 2009 - 14:25
| Project: | Rules |
| Version: | 6.x-1.x-dev |
| Component: | Provided module integration |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Hello,
I created a condition "when node is created"
and trying to add an action "add a new vocabulary"
I would like to name this vocabulary the same as the node that was created, yet there seem to be no tokens for this.
Can someone give me advice on how I could achieve this?

#1
Use the event 'Content has been saved', so you'll have the node tokens.
#2
Hi Amitaibu,
Thanks for replying. Yes I think I have all set, except the tokens do not appear somehow.
I added to the "content has been saved" a further criteria, namely content is a group.
Here is my exported rule, basically it creates a vocab for a group on group creation. Yet, if you try and import this yourself you wont see the node tokens for naming the taxonomy, when editing the "add new taxonomy" action.
Any ideas are appreciated.
(one needs og, og_vocab for this rule)
array ('rules' =>
array (
'rules_2' =>
array (
'#type' => 'rule',
'#set' => 'event_node_insert',
'#label' => 'group vocab',
'#active' => 1,
'#weight' => '0',
'#categories' =>
array (
0 => 'group',
),
'#status' => 'custom',
'#conditions' =>
array (
0 =>
array (
'#type' => 'OR',
0 =>
array (
'#type' => 'condition',
'#settings' =>
array (
'#argument map' =>
array (
'group' => 'node',
),
),
'#name' => 'og_rules_condition_content_is_group',
'#info' =>
array (
'label' => 'Content is a group',
'arguments' =>
array (
'group' =>
array (
'type' => 'node',
'label' => 'Group',
),
),
'module' => 'Organic groups',
),
'#weight' => 0,
),
'#weight' => 0,
),
),
'#actions' =>
array (
0 =>
array (
'#weight' => 0,
'#info' =>
array (
'label' => 'Add a new vocabulary',
'new variables' =>
array (
'taxonomy_vocab' =>
array (
'type' => 'taxonomy_vocab',
'label' => 'Taxonomy vocabulary',
),
),
'module' => 'Taxonomy',
),
'#name' => 'rules_action_taxonomy_add_vocab',
'#settings' =>
array (
'name' => 'test',
'description' => '',
'help' => '',
'nodes' =>
array (
'group' => 'group',
),
'tags' => 0,
'multiple' => 0,
'required' => 0,
'weight' => '0',
'hierarchy' => '0',
'relations' => '1',
),
'#type' => 'action',
),
1 =>
array (
'#weight' => 0,
'#info' =>
array (
'label' => 'Assign vocabulary to group',
'arguments' =>
array (
'group' =>
array (
'type' => 'node',
'label' => 'Group',
),
'taxonomy_vocab' =>
array (
'type' => 'taxonomy_vocab',
'label' => 'Taxonomy vocabulary that will be assigned to group',
),
),
'module' => 'Organic groups vocabulary',
),
'#name' => 'og_vocab_rules_action_assign_vocab',
'#settings' =>
array (
'#argument map' =>
array (
'group' => 'node',
'taxonomy_vocab' => 'taxonomy_vocab',
),
),
'#type' => 'action',
),
),
),
),
'rule_sets' =>
array (
),
)
#3
I just tried this rule without the organic group action, meaning only the condition where "node is saved" and the action "add new taxonomy"
but the tokens are missing there as well.
Any suggestions are welcome.
#4
Ok, from looking in te code there's no eval input defined for the add taxonomy - I'll roll a patch for that.
#5
Attached ptach adds token/ PHP eval support.
#6
Thanks Amitaibu.
Works wonders.
#7
Hoops, maybe I spoke too soon
The tokens appear fine, but now when I try to create now a new group, I get this:
Fatal error: Cannot use object of type stdClass as array in .../sites/all/modules/og_vocab/og_vocab.rules.inc on line 54
Here is the export of the rule with the token this time :)
array ('rules' =>
array (
'rules_5' =>
array (
'#type' => 'rule',
'#set' => 'event_node_insert',
'#label' => 'group vocab',
'#active' => 1,
'#weight' => '0',
'#categories' =>
array (
),
'#status' => 'custom',
'#conditions' =>
array (
0 =>
array (
'#weight' => 0,
'#info' =>
array (
'label' => 'Content is a group',
'arguments' =>
array (
'group' =>
array (
'type' => 'node',
'label' => 'Group',
),
),
'module' => 'Organic groups',
),
'#name' => 'og_rules_condition_content_is_group',
'#settings' =>
array (
'#argument map' =>
array (
'group' => 'node',
),
),
'#type' => 'condition',
),
),
'#actions' =>
array (
0 =>
array (
'#type' => 'action',
'#settings' =>
array (
'name' => '[node:title]',
'description' => '',
'help' => '',
'nodes' =>
array (
'group' => 'group',
),
'tags' => 1,
'multiple' => 0,
'required' => 0,
'weight' => '0',
'hierarchy' => '0',
'relations' => '1',
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'name' =>
array (
0 => 'node',
),
),
),
),
'#name' => 'rules_action_taxonomy_add_vocab',
'#info' =>
array (
'label' => 'Add a new vocabulary',
'new variables' =>
array (
'taxonomy_vocab' =>
array (
'type' => 'taxonomy_vocab',
'label' => 'Taxonomy vocabulary',
),
),
'eval input' =>
array (
0 => 'name',
1 => 'description',
2 => 'help',
),
'module' => 'Taxonomy',
),
'#weight' => 0,
),
1 =>
array (
'#weight' => 0,
'#info' =>
array (
'label' => 'Assign vocabulary to group',
'arguments' =>
array (
'group' =>
array (
'type' => 'node',
'label' => 'Group',
),
'taxonomy_vocab' =>
array (
'type' => 'taxonomy_vocab',
'label' => 'Taxonomy vocabulary that will be assigned to group',
),
),
'module' => 'Organic groups vocabulary',
),
'#name' => 'og_vocab_rules_action_assign_vocab',
'#settings' =>
array (
'#argument map' =>
array (
'group' => 'node',
'taxonomy_vocab' => 'taxonomy_vocab',
),
),
'#type' => 'action',
),
),
),
),
'rule_sets' =>
array (
),
)
#8
I think the error is from og_vocab -are you using latest version?
#9
Thanks, good call. I had og_vocab rc1, but I installed the dev from May, and now it works fine.
I can create group with the rule created and taxonomy with the same name is assigned.
Much appreciated.
Cheers,
G
#10
thanks, committed.
#11
Automatically closed -- issue fixed for 2 weeks with no activity.