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?

CommentFileSizeAuthor
#5 512566-eval-add-vocab.patch675 bytesamitaibu

Comments

amitaibu’s picture

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

giorgio79’s picture

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 (
  ),
)

giorgio79’s picture

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.

amitaibu’s picture

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

amitaibu’s picture

Title: "Add a new vocabulary" (action) tokens for vocabulary name missing » Add eval input to "Add a new vocabulary" action
Category: support » task
Status: Active » Needs review
StatusFileSize
new675 bytes

Attached ptach adds token/ PHP eval support.

giorgio79’s picture

Status: Needs review » Reviewed & tested by the community

Thanks Amitaibu.

Works wonders.

giorgio79’s picture

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 (
  ),
)

amitaibu’s picture

Status: Needs work » Needs review

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

giorgio79’s picture

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

fago’s picture

Component: User interface » Provided module integration
Status: Reviewed & tested by the community » Fixed

thanks, committed.

Status: Fixed » Closed (fixed)

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

mitchell’s picture

Component: Provided module integration » Provided Module Integrations

Updated component.