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

Amitaibu - July 7, 2009 - 14:27

Use the event 'Content has been saved', so you'll have the node tokens.

#2

giorgio79 - July 7, 2009 - 15:06

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

giorgio79 - July 8, 2009 - 04:56

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

Amitaibu - July 8, 2009 - 06:30

Ok, from looking in te code there's no eval input defined for the add taxonomy - I'll roll a patch for that.

#5

Amitaibu - July 8, 2009 - 07:05
Title:"Add a new vocabulary" (action) tokens for vocabulary name missing» Add eval input to "Add a new vocabulary" action
Category:support request» task
Status:active» needs review

Attached ptach adds token/ PHP eval support.

AttachmentSize
512566-eval-add-vocab.patch 675 bytes

#6

giorgio79 - July 8, 2009 - 11:35
Status:needs review» reviewed & tested by the community

Thanks Amitaibu.

Works wonders.

#7

giorgio79 - July 8, 2009 - 11:54
Status:reviewed & tested by the community» needs work

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

Amitaibu - July 8, 2009 - 12:25
Status:needs work» needs review

I think the error is from og_vocab -are you using latest version?

#9

giorgio79 - July 8, 2009 - 13:06
Status:needs review» reviewed & tested by the community

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

fago - July 10, 2009 - 12:52
Component:User interface» Provided module integration
Status:reviewed & tested by the community» fixed

thanks, committed.

#11

System Message - July 24, 2009 - 13:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.