6

In D7, it seems the token for fields (e.g., [node:field_date]) just returns the rendering of the field. So if the field is multi-valued, this token returns all the values rendered together. However, I'd like to be able to access specific delta values of the field separately using tokens, e.g. using [node:field_date:0] or similar syntax. I also want to be able to chain the token, e.g. [node:field_date:0:long].

Has this been done before? My solution would be to use hook_token_info_alter to mark the field's token as dynamic, then do my own parsing in hook_tokens_alter. But if I do this, will I lose the ability to chain the token?

1

Have you tried Entity Tokens? It's part of Entity API module.

There are long discussions about date tokens: Date issue about date tokens and Entity Token issue about multi-value field tokens.

| improve this answer | |
0

For Date fields there are 3 available values to use...

[node:field-date:value]    = Start date
[node:field-date:value2]   = End date
[node:field-date:duration] = Well... Duration. :-)

/marcus

| improve this answer | |
  • Thanks but that's not what I'm looking for. In a multi-valued field_date, I'd like to access value 1, value 2, value 3, etc. – infojunkie Nov 29 '12 at 19:20
  • Sorry. Then I would assume that something like [node:field_foo:value:?] where ? is the Delta. But it seems to only work for taxonomy term parents... :-( – Marcus Farrington Nov 30 '12 at 10:03
0

I found I needed to use the Compound Token module for this.

Works with vanilla Token:

[node:field_my_field]

Throws errors with vanilla Token; Works after installing Compound Token:

[node:field_my_field:und:0:value]
| improve this answer | |

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.