3

Oke, so I have this multi value field in drupal 7 and I want to use it's values in a custom php snippet in the rules module.

I found the Array Tokens module to generate an array of the values, but that is for Drupal 6.

Then I found Architecture RFC: Field token architecture, which makes me assume I could use [node:field-name:0] or [node:field-name:value:0] to read the first entry, but I either replaces nothing of throws an error (I have tried various combinations).

Could someone tell me:

  1. What is the right way to read a token with it's delta value?
  2. How to get the delta of the fields so I can start a for loop?
0

Since the rules module gives you access to the $node object (if triggered on 'after saving content'). I managed to use it like this $node->field_myField['und'][0]['value']. Where 0 is the delta and und (probably) the language.

Since this looks like a multidimensional array I assume one could use a foreach on $node->field_myField['und'], but I did not test this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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