Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
I have created a custom content with a Term reference field (with an autocomplete widget).
That term reference field is called 'test' for the example.
I would like to be able to have access to the name of the term parents with the token module.
How to do it?
In my 'token' help, there is just an entry test [node:field_test] Term reference field.
How to have access to its parents?
Comment | File | Size | Author |
---|---|---|---|
#17 | token-ref-multi-value-1487990-17.patch | 979 bytes | oddz |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedLooks like a bug, I'm trying to understand why... and I will post a bug report.
By disabling/enabling the Entity Token, their is a tree under 'test' term reference field.
Comment #2
ckngHaving the same problem, but disabling/enabling the Entity Token does not solve it.
It turns out that when the term reference field is having multiple values, the token and sub-token are all missing.
e.g. you only get (note the underscore) that does not work
which should be
when multiple values setting is removed, the tokens reappear.
Comment #3
ckngThis belongs to Entity Tokens.
Latest dev solves the token tree not showing (as fixed in #1058856: Entity tokens not created for multi-value fields).
However, the replacement for the token failed.
e.g
[node:field-test:1:name]
[node:field-test:2:name]
So "list" for term reference field not quite working.
Comment #4
ezra-g CreditAttribution: ezra-g commentedI marked #1520420: Entity tokens for multi-value fields still not working (or need documention). as a duplicate.
Comment #5
ezra-g CreditAttribution: ezra-g commentedI referenced this issue from a comment on #1834946: Implement email notifications & UI with Message Subscribe -- I believe the problem is the same -- The body token for a referenced entity isn't being replaced with a multi-value entity reference field. In my case, it references nodes.
Comment #6
aelling CreditAttribution: aelling commentedI can confirm this is happening as well. For example if you implement a date field and check to "Include an end date" the field date tokens are not available for use. If you keep it just a single value field then the tokens are available for use.
Comment #7
rakun CreditAttribution: rakun commentedIs there anything new about this?
Comment #8
Andre-Bthis still bugs me. any news on this?
Comment #9
suldan CreditAttribution: suldan commentedEven if #1520420: Entity tokens for multi-value fields still not working (or need documention) should be a duplicate of this, the problem is still unsolved. Need to get a single value out of a multiple value image field for og:image.
Comment #10
laura s CreditAttribution: laura s commentedI'm running up against this as well. An ability to add an argument (e.g., ?0 for image 0) would be wonderful.
Comment #11
pbattino CreditAttribution: pbattino commentedSame here.
Comment #12
shortspoken CreditAttribution: shortspoken commented+ subscribing
Comment #13
ezra-g CreditAttribution: ezra-g commentedIn some cases, you may be able to resolve this issue by clearing the Entity load static cache before token replacement takes place. Here's how I resolved the problem in a very early Commons 3.x dev commit: http://drupalcode.org/project/commons_notify.git/blobdiff/2dc2468d7d5470....
Comment #14
jlyon1515 CreditAttribution: jlyon1515 commentedHas there really not been an update to this yet? I would like to be able to use something like:
[node:field-event-date:value:custom:m-d-Y]
in my alias replacement patterns, but when date is set to repeating or having a start and end date, tokens seem to no longer be available.
The patch here:
https://drupal.org/node/1440928#comment-7795885
does fix a fatal error from occurring if I've set my pattern incorrectly, but this token issue is still unresolved.
Comment #15
Matt BThis is in issue for me on 7.x-1.5
Comment #16
Collins405 CreditAttribution: Collins405 commentedSame problems
Comment #17
oddz CreditAttribution: oddz commentedLooks like the problem was caused by the delta being incorrect. The fix is merely a matter of decrementing the delta by one.
Comment #18
kopeboy CreditAttribution: kopeboy commentedWhat if I don't want to hardcode the delta value because I don't know how many values there are?
Is it possible to get all the names with a single token?
Currently I can get all the references but I cannot get a field of all the references.
Comment #19
Nathan Hall CreditAttribution: Nathan Hall commentedI was working with autosku module to setup sku numbers correlating to the initial date of events. [commerce-product:field-event-date:value:custom:Ymd]
I found this thread and implemented the patch and immediately restored back to the baseline. I read the code again and found that the documentation of this feature seems to not articulate the use of multi-valued date/time well:
date:0:value (here 0 represents the first date with the starting time )
date:0:value2 (here 0 represents the first date with the ending time )
date:0:duration (here 0 represents the first date with the duration from start to finish )
increase the digit to reflect each additional day.
[commerce-product:field-event-date:0:value:custom:Ymd]
Works like a champ!
Comment #20
oddz CreditAttribution: oddz commentedThe patch I submitted six months ago hasn't made it core… (shrug)
Comment #21
ron_s CreditAttribution: ron_s commented@oddz, thanks for taking time to investigate this. I added your patch to 7.x-1.6, and found that it caused problems when attempting to access date fields connected to another content type through Inline Entity Form (https://www.drupal.org/project/inline_entity_form).
When I had the patch included, I received no results from the token. Once the patch was removed, it worked correctly again.
Here is an example... a Date field (
field_date
) is attached to an Event content type, which is embedded in a Program content type via Inline Entity Form (and accessed through "field_events
"). We're accessing the start date value from the Program by token:[node:field-events:0:field-date:0:value]
So we're trying to display the 0th
field_events
attached to the Program, and the 0thfield_date
within that event.