Current status of this issue:
- The standard way of providing tokens for fields like Date will be using the Token module, but the only thing currently supported is a default token format for the field as a whole. No way to indicate whether you want the start or end date or both or how you want it formatted, you get both dates formatted as the raw value stored in the field.
- Further work on Token module is blocked by questions about architecture and handling nested tokens and there has been no movement on them in quite some time. (see #1222592: Architecture RFC: Field token architecture and #1195874: Need to figure out how to create nested tokens from the array token type)
- An alternative way of handling tokens is provided by the Entity Tokens module (part of Entity API). It is fixed by the Entity patch at http://drupal.org/node/1058856#comment-5281650 in #1058856: Entity tokens not created for multi-value fields. If that gets committed, you can create Date tokens using Entity Tokens. The Entity Tokens are the ones that uses dashes instead of underscores in the token names.
- At the moment, Token and Entity Token are incompatible (see #1272560: Entity tokens duplicates field tokens created by token module because one defines tokens using underscores and one using dashes, resulting in duplication of all the field tokens, a big problem if there are lots of fields.
- Because of the conflict between Entity Tokens and Token noted above, it is possible Entity Tokens will change to using underscores, resulting in a need to change all your tokens, so you should keep an eye on #1272560: Entity tokens duplicates field tokens created by token module.
Comment | File | Size | Author |
---|---|---|---|
#29 | date-1103032-29.patch | 1.59 KB | tim.plunkett |
Comments
Comment #1
johnvsubscribe. I have some more messages:
Notice: Undefined index: date-field in _token_build_tree() (line 736 of \token\token.module).
Warning: Invalid argument supplied for foreach() in _token_build_tree() (line 736 of \token\token.module).
Notice: Undefined index: datestamp-field in _token_build_tree() (line 736 of \token\token.module).
Warning: Invalid argument supplied for foreach() in _token_build_tree() (line 736 of \token\token.module).
Notice: Undefined index: datetime-field in _token_build_tree() (line 736 of \token\token.module).
Warning: Invalid argument supplied for foreach() in _token_build_tree() (line 736 of \token\token.module).
Comment #2
joostvdl CreditAttribution: joostvdl commentedsubscribe
Issue also in token module announced: #1103286: Notices and warnings - date-field
Comment #3
metakel CreditAttribution: metakel commentedSame error messages, but I got error at line 737.
Comment #4
BrightBoldsubscribing
Comment #5
jeff_c CreditAttribution: jeff_c commentedsubscribe
Comment #6
BParticle CreditAttribution: BParticle commentedSubscribing
Comment #7
clauded CreditAttribution: clauded commentedsubscribe
Comment #8
sebish CreditAttribution: sebish commentedSubscribe
Comment #9
joeyabbs CreditAttribution: joeyabbs commentedSubscribing
Comment #10
cutmedia CreditAttribution: cutmedia commentedsubscribing
Comment #11
sahaj CreditAttribution: sahaj commentedsubscribing
Comment #12
bensnyder CreditAttribution: bensnyder commentedsubscribe
Comment #13
BrightBoldJust to add more details, I get the same errors as in #1. I am using the most recent versions of Date and Token — Date 7.x-2.x-dev from March 28 and Token 7.x-1.x-dev from Feb 25. The error seems to occur only on the Modules page whenever I enable a new module.
Comment #14
modstore CreditAttribution: modstore commentedsubscribe
Comment #15
rumblewand CreditAttribution: rumblewand commentedsubscribed
Comment #16
Steven.Pescador CreditAttribution: Steven.Pescador commentedSubscribing
Comment #17
acoustika CreditAttribution: acoustika commented+1
Comment #18
Linus CreditAttribution: Linus commented+1
Comment #19
weri CreditAttribution: weri commentedSubscribing
Comment #20
zabelc CreditAttribution: zabelc commentedI'm seeing the same thing with the following:
date-7.x-2.x-dev (4/5)
token-7.x-1.x-dev (2/25)
Entity tokens-7.x-1.0-beta8 (3/21)
Comment #21
Oceanman CreditAttribution: Oceanman commentedThis is my error if I enable the Token module with these others.
Token 7.x-1.x-dev
Date 7.x-2.x-dev
Entity tokens 7.x-1.x-dev
* Notice: Undefined index: date-field in _token_build_tree() (line 736 of /token/token.module).
* Warning: Invalid argument supplied for foreach() in _token_build_tree() (line 736 of /token/token.module).
* Notice: Undefined index: datestamp-field in _token_build_tree() (line 736 of /token/token.module).
* Warning: Invalid argument supplied for foreach() in _token_build_tree() (line 736 of /token/token.module).
* Notice: Undefined index: datetime-field in _token_build_tree() (line 736 of /token/token.module).
* Warning: Invalid argument supplied for foreach() in _token_build_tree() (line 736 of /token/token.module).
This might be related to the solution to this but I'm not sure: http://drupal.org/node/1054812
Comment #22
zabelc CreditAttribution: zabelc commentedBased on Oceanman's link I think I've gotten rid of the errors.
In looking at date_token_info() in date.tokens.inc I noticed that only the $info['types']['date-field-value'] had any corresponding $info['tokens']['date-field-value'] entries; whereas date-field, datestamp-field, and datetime-field only appeared in $info['types'].
Thus I removed those types entries so that the function appears as follows:
While this does get rid of the errors, I wonder that it means that date-field, datestamp-field, and datetime-field won't be available as tokens (I don't think I'll be needing them but someone else might)
Comment #23
Dave ReidNot sure why this chunk of code was committed to Date module for D7 already. Field token support is not yet ready nor fully baked in Token module: #691078: Field tokens
Comment #24
BrightBoldAwesome. Thanks Oceanman, zabelc, and Dave Reid for getting to the bottom of this. I'll be happy to get rid of those errors!
Comment #25
BParticle CreditAttribution: BParticle commentedThank you all for helping me getting rid of those errors! Works for me!
Comment #26
pauljr8 CreditAttribution: pauljr8 commentedHello, I am interested in what the final verdict is on this problem. Is the fix mentioned above by zabelc the final answer? If so, how would I implement it, e.g. which file to alter? Or, if a fix is in the works and forthcoming, please advise and I'll be quiet and wait for it.
Thanks
Comment #27
BrightBold@pauljr8 - It looks like you have three choices (@DaveReid correct me if I'm wrong!):
Since I only get the errors on the Modules page, I may actually go with #3, trusting it will sort itself out eventually.
Comment #28
pauljr8 CreditAttribution: pauljr8 commentedThanks. Waiting for the upgrade makes sense to me as well.
Comment #29
tim.plunkettPatch to hold everyone over until #691078: Field tokens is in.
Comment #30
HnLn CreditAttribution: HnLn commentedsub
Comment #31
KarenS CreditAttribution: KarenS commentedCommit the patch in #29. If there is something else to be done let me know.
Comment #32
tim.plunkettFor future reference, using `git am date-1103032-29.patch` would give proper git credit when the patches are rolled with headers like that one.
Comment #33
basicmagic.net CreditAttribution: basicmagic.net commentedsubscribe
Comment #34
KarenS CreditAttribution: KarenS commentedThe git instructions say to use "Issue #1103032, by tim.plunkett...", which is what I did.
Comment #36
Starminder CreditAttribution: Starminder commentedprematurely closed -
Comment #37
tim.plunkett@starminder
In what way?
Comment #38
Starminder CreditAttribution: Starminder commentedIn one of the other threads concerning date, if you use the release version you get different errors and the recommendation is to use the dev version. If you use the dev version you get this. Rock or hard place.
Comment #39
bfroehle CreditAttribution: bfroehle commentedOkay, so token support is currently blocked on #691078: Field tokens, but when that goes in, we can simply revert the patch in #29 to get basic field token support.
Comment #40
sachbearbeiter CreditAttribution: sachbearbeiter commentedsubscribe
Comment #41
davidd07 CreditAttribution: davidd07 commentedThe title of this thread is "Re-Add Field Token Support" but all I can see is the opposite, removing token support. I actualy need token support for the DATE module, so I can use in paths. I have applied the most recent patch for token http://drupal.org/node/691078 This allows me to see all node fields, however still no Date field, in path auto token list. Only default Drupal dates. Any help much apprectiated. I have installed Date 7.x-2.x-dev
Comment #42
tim.plunkett@davidd07, it was removed since #691078: Field tokens isn't committed yet, and the code was broken. Once that issue is fixed, the date token support can be readded.
Comment #43
hansfn CreditAttribution: hansfn commentedsubscribe
Comment #44
Shadlington CreditAttribution: Shadlington commentedSubbing
Comment #45
adamdicarlo CreditAttribution: adamdicarlo commentedOT: @KarenS, see http://drupal.org/node/1146430 -- I've been wondering recently how to give proper attribution to patch authors, so I just dug that up after seeing tim.plunkett's comment here. As far as I understand it, d.o will actually use the commit's metadata and credit the commit to the author rather than the committer.
Comment #46
KarenS CreditAttribution: KarenS commentedI have been following the instructions at http://drupal.org/project/date/git-instructions. If I'm supposed to be doing something different someone should change that information.
Comment #47
KarenS CreditAttribution: KarenS commentedPlus I can't tell from that link how I know which way the patch was created. And if I'm supposed to do the second option I have to go find the patch author's email address, which ordinarily isn't available anywhere, so I don't know how I'd do that either.
I'm already struggling with patches created different ways that have to be applied different ways. I'm more than happy (delighted! excited!) to get other people making patches, and I want to give them credit for doing so, but all of this means it's taking a lot more time to review and commit patches.
The last patch I committed cost me a half hour of screwing around to find the right way to apply it and give the author credit, and then I still got it wrong :(
Comment #48
tim.plunkettIn the case of http://drupal.org/files/issues/date-1103032-29.patch, the header part with my name and email address signifies it can be applied with
git am foo.patch
, otherwise you'd have to go look it up and dogit apply foo.patch && git commit --author ...
Which is confusing and time consuming and not really documented! Which is why I don't take offense when someone doesn't commit my patches that way. Also, it only works when one person wrote the patch, because you can't list more than one author. So not really a big deal.
Anyway, thanks for caring/responding about this Karen. I can't wait to roll the next patch for this issue!
Comment #49
wjaspers CreditAttribution: wjaspers commentedsubbing.
Comment #50
mariagwyn CreditAttribution: mariagwyn commentedsub
Comment #51
JamFar CreditAttribution: JamFar commentedBoy, if even KarenS struggles with making and applying these patches, maybe Dries needs to rethink how this is being done and get it simplified for everyone?
Comment #52
tim.plunkett@JamFar, it has nothing to do with KarenS "struggling", or Dries "rethinking". It's merely a documentation issue, which anyone can contribute to. Please don't be so disparaging.
Comment #53
MrPaulDriver CreditAttribution: MrPaulDriver commentedPlease would someone mind advising me of the latest with this issue.
From what I read the changes for Issue #691078: Field tokens have now been implemented as of Aug 17, the current release being Token Beta 5. And, as far as I can see, the Date token is now available.
If this is the case. Is the patch at #29 still relevant? - I notice that tim.plunket says [it is a] "Patch to hold everyone over"
Without applying any patch, I find that Date token still doesn't print (for me).
So where to go now? Any help much appreciated.
Comment #54
KarenS CreditAttribution: KarenS commentedThe only thing that has hit so far is a basic plain text field. We need to add a 'default token formatter' to the Date module that provides the raw value in the date field as its output. That is way short of what is really needed here, which are ways to allow you to do things like create tokens that display the token in some specified format, properly taking into account things like the timezone and granularity of the field. Those things are waiting on #1222592: Architecture RFC: Field token architecture and #1195874: Need to figure out how to create nested tokens from the array token type.
So this is still postponed.
Comment #55
KarenS CreditAttribution: KarenS commentedAnd to clarify, the 'Patch to hold everyone over' was a patch to completely remove token support until it's working, so you don't need to apply any patch (it's already applied) and you will not see any tokens until the core issues are resolved.
Comment #56
MrPaulDriver CreditAttribution: MrPaulDriver commentedThank you Karen.
I didn't realise the complexity and look forward to seeing the issue resolved.
Comment #57
bennybobw CreditAttribution: bennybobw commentedsubbing
Comment #58
kenianbei CreditAttribution: kenianbei commentedsubscribe
Comment #59
webchickTagging.
Comment #60
KarenS CreditAttribution: KarenS commentedAs a temporary measure, I added a new date plain formatter that just spits out the stored value of the date field, whatever it is. It does not timezone conversion, no formatting of the output, just the raw value. Not sure how useful that is but doing much more would require the Token field support that isn't working yet so you could choose exactly what you want done with it.
Comment #61
fagoFYI, date tokens already work via the entity tokens module (shipping with the entity api). In case the date field is multiple though, the patch from #1058856: Entity tokens not created for multi-value fields is required.
Comment #62
KarenS CreditAttribution: KarenS commentedBut all Entity token does is give us the raw value of the date. There is no way to select a format for the date or anything else.
Comment #63
Dig1 CreditAttribution: Dig1 commentedThe entity tokens module is a neat alternative to use as long as you do not need an end date.
If you need an end date then as per #61 a patch is needed. Unfortunately neither of those patches work at the moment, I got:
and
Cheers
Comment #64
fago>But all Entity token does is give us the raw value of the date. There is no way to select a format for the date or anything else.
All regular date token replacements as defined by system.module are available via token chaining, but I think token module also exposed more stuff like the custom date formats.
Comment #65
BrightBoldRight — in Pathauto, I can set a path for
article/[node:created:custom:Y]/[node:created:custom:m]/[node:created:custom:d]/[node:title]
but even with Entity Tokens enabled,calendar/[node:field_event_date:custom:Y]/[node:field_event_date:custom:m]/[node:field_event_date:custom:d]/[node:title]
gives me an invalid token message. So it seems to me we still really need this functionality!Comment #66
fago[node:field_event_date:custom:d] is probably provided by the token module, entity tokens uses dashes. Try [node:field-event-date:custom:d]
Comment #67
KarenS CreditAttribution: KarenS commentedIf I enable Entity Tokens, no date tokens other than the top-level one ([node:field_date]) appear in the replacement patterns. If I just try to force in value in the pathauto settings like [node:field-date:custom:d], I get errors like 'The Default path pattern for Date (applies to all Date content types with blank patterns below) is using the following invalid tokens: [node:field-date:custom:d].';
What am I missing?
Comment #68
KarenS CreditAttribution: KarenS commentedTried another installation and it worked better. Dates that have no ending date had nested tokens. Dates with an ending date had none. And for the ones where the nested tokens get added there are two, on with underscores and one with dashes. And they both show up as being expandable even though only the one with dashes is actually expandable (probably because they have the same id in the source code).
Anyway I'll have to try to sort out what is the difference between the site that works and the one that doesn't.
Comment #69
KarenS CreditAttribution: KarenS commentedOK, the difference between the dates that work and the ones that don't is that the working dates have 'date' properties and the non-working ones have 'struct' properties in the array created by entity_get_all_property_info().
I think this goes back to the way the Date property setter callback works, which is code I am completely unfamiliar with. The related issue is probably #1153766: provide a property setter callback.
If that could be fixed by someone who understands that part of the code we can say that tokens will work if you use the Entity Tokens module, which would keep this issue from blocking a release. Then when the Token module gets nested field token support working we can do whatever is needed to incorporate that.
Comment #70
fagoah, yes there is still #1183676: improve support for arbitrary data structures. If you have a start and an end-date, there is no simple "date" property but a struct containing both dates. In that case tokens do not yet work - I'll have a look at that.
Comment #71
fago#1058856-22: Entity tokens not created for multi-value fields contains a patch for entity-tokens, what makes list-tokens work and adds basic data-structure-token support. Thus with that patch, you should get working date-tokens (using the "dash-ed" field names) - please test!
Comment #72
BrightBoldIs this dependent on a certain version of Date? I am using the latest version of Entity with the patch (and hyphenated tokens) but still get an error. It occurs to me that I froze Date at alpha3 until Calendar 7.3 is a little farther along (because I know it's recommended to upgrade them in tandem, so since they are working fine now I thought I'd sit tight until Calendar looked stable). I want to help test this but shouldn't be weighing in if the fact I'm using an older version of Date means I won't get accurate results.
Comment #73
KarenS CreditAttribution: KarenS commentedYou should be using latest dev version of Date and Entity and Token for testing things like this. And you shouldn't be testing them on a production site, try it on a test site with the dev versions of everything.
I had some success with that patch but still some problems, and I commented on that issue.
Comment #74
KarenS CreditAttribution: KarenS commentedCurrent status of this issue:
- The standard way of providing tokens for fields like Date will be using the Token module, but the only thing currently supported is a default token format for the field as a whole. No way to indicate whether you want the start or end date or both or how you want it formatted, you get both formatted in as the raw value stored in the field.
- Further work on Token module is blocked by questions about architecture and handling nested tokens and there has been no movement on them in quite some time. (see #1222592: Architecture RFC: Field token architecture and #1195874: Need to figure out how to create nested tokens from the array token type)
- An alternative way of handling tokens is provided by the Entity Tokens module (part of Entity API). It too is broken at the moment but fago is working on the issue so hopefully that will be fixed soon. See #1183676: improve support for arbitrary data structures)
- At the moment, Token and Entity Token are incompatible (see #1272560: Entity tokens duplicates field tokens created by token module because one defines tokens using underscores and one using dashes, resulting in duplication of all the field tokens, a big problem if there are lots of fields.
I'm going to copy this information into the issue summary.
Comment #75
KarenS CreditAttribution: KarenS commentedAlso back to critical
Comment #75.0
tim.plunkettUpdate the issue summary
Comment #75.1
KarenS CreditAttribution: KarenS commentedUpdate for possible fix for Entity Tokens
Comment #78
KarenS CreditAttribution: KarenS commentedEntity tokens are now working using the patch at http://drupal.org/node/1058856#comment-5281650. If that gets committed you can create Date tokens using the Entity Tokens module (part of http://drupal.org/project/entity). The Entity tokens are the ones that use dashes instead of underscores in the names.
Because of the conflict between Entity Tokens and Token noted above, it is possible Entity Tokens will change to using underscores, resulting in a need to change all your tokens, so you should keep an eye on #1272560: Entity tokens duplicates field tokens created by token module.
Comment #78.0
KarenS CreditAttribution: KarenS commentedAdd note that Entity Tokens may change to using underscores.
Comment #79
mariagwyn CreditAttribution: mariagwyn commentedKaren,
I have just installed the dev version of entity and am running the alpha5 version of date. I am trying to get this url pattern:
meetings/[node:field-sess-assoc-meeting:field_event_dates]/papers/[node:title]
to be this:
meetings/[node:field-sess-assoc-meeting:field_event_dates:custom:Y]/papers/[node:title]
If I read your post above correctly, this should work: "meetings/[node:field-sess-assoc-meeting:field-event-dates]/papers/[node:title], but this generates an error. What am I missing? should I be on the dev version of date? Should I construct the pattern differently? Do I need to turn something off (token...)? Or have I jumped the gun on custom dates....
Thanks,
Maria
quick followup: with the dashes, no error is genderated, but the value is this: "property-fieldeventdates" in the token spot of the url.
Comment #80
mariagwyn CreditAttribution: mariagwyn commentedAnother update: the token does work, but the custom:y does not.
So, did I jump the gun on the custom part, or am I missing something that will get this to work?
Maria
Comment #81
mariagwyn CreditAttribution: mariagwyn commentedFirst, let me apologize: I try something, test, doesn't work, then post a comment. Then I walk away from my desk in disgust. Then I come back, and lo and behold, try something else, and it DOES work.
Second: custom dates do work. This gets exactly what I want: meetings/[node:field-event-dates:value:custom:Y]/details
Comment #82
KarenS CreditAttribution: KarenS commentedNotice the difference between "field_event_dates" and "field-event-dates". The first is what Token module provides and it does not work. The second is what Entity Token provides and it does work. The fact that there are two different patterns for the same field is the conflict problem that needs to be resolved, it is both confusing and creates performance problems (the tokens are duplicated).
And the 'walk away and it starts to work' may be that the cache needed to be cleared.
Comment #83
mariagwyn CreditAttribution: mariagwyn commentedKaren,
I did notice the difference between the two, and had it working with the hyphens. Now, with the recent date upgrade, I am having problems. Sigh.
Until the update, this worked:
meetings/[node:field-event-dates:value:custom:Y]/details
Now, all that works is this:
meetings/[node:field_event_dates]/details, which is the Token module, not the entity module.
Is this b/c the entity tokens and date module are not playing well together? Or do you know of another change?
Comment #84
KarenS CreditAttribution: KarenS commentedI'm not sure exactly what 'the recent Date upgrade' means. Are you using the latest dev code or the older alpha release? Be sure you have the latest dev version of all the related modules, I have no idea what will work otherwise. If there's still a problem there, some change may have introduced a new problem, but please confirm that.
Comment #85
mariagwyn CreditAttribution: mariagwyn commentedrecent dev version of Date, showing errors. I just uploaded the most recent dev, from Dec 14.
Comment #86
mariagwyn CreditAttribution: mariagwyn commentedI take it back. with dev versions of all related modules, seems to be working fine. sorry, forgot to move the others to dev rather than rc's.
Comment #87
KarenS CreditAttribution: KarenS commentedSince there is a work-around, I'm taking this off the list of release blockers.
Comment #88
Kevin Morse CreditAttribution: Kevin Morse commentedHi guys,
I need to implement the following for Pathauto
events/[node:field-dateandtime:value:custom:Y]/[node:title]
What steps/modules need to be installed to do this?
My Date field has year, month, day, hour, min and start and stop times.
Thanks for your help.
Comment #89
fagoI don't think this will be an issue. Even *if* we would change it to do so for whatever reason, we would keep dashed tokens working too.
Comment #90
mattbk CreditAttribution: mattbk commentedsubscribe
Comment #91
KarenS CreditAttribution: KarenS commentedYou don't need to 'subscribe', just use the 'Follow' link at the top of the issue. That way everyone who is following won't get emailed every time someone else subscribes. Thanks!
Comment #92
NicolasH CreditAttribution: NicolasH commentedSo with the regular token I get a start and an end date (if one was specified).
However, the timezone is out.
Entity tokens appear to do a proper timezone conversion, but AFAICT they wouldn't allow for an optional end date (without having a " to " there - I can't use conditionals where this gets displayed).
Any ideas?
Comment #93
KarenS CreditAttribution: KarenS commentedThe thing you're trying to do in #92 is probably not possible currently. We need better tokens, but it's pointless to add any code for this until the underlying modules are finished, because the final changes may end up breaking anything we try to do in the interim.
Comment #94
NicolasH CreditAttribution: NicolasH commentedThanks Karen, getting by for now with hook_tokens_alter() then...
Comment #95
bryancasler CreditAttribution: bryancasler commentedThe following work for me
Comment #96
BrightBoldAah! Thanks @animelion — I was missing
value:
— that appears to be why mine weren't working. Awesome to have this fixed before the site goes live!Comment #97
pyrello CreditAttribution: pyrello commentedThis also worked for me:
Comment #98
liquidcms CreditAttribution: liquidcms commentedsorry, but can someone summarize what is required to piece this together?
this is what i have:
- latest -dev of Date
- latest -dev of Entity API (also latest -dev of i18n since without it e-api crashes the site: #1462984: Internal Server Error with latest dev)
(flushed caches)
i still only get the same tokens (for ANT) that i had before all of this, at least as far as what is listed under Replacement Patterns:
i have no field based tokens with "-".
are they possibly not listed and we just need to guess at the format?
as in #95 above i tried this:
[node:field-appmt-date:value:custom:Y]
this doesn't work.
Comment #99
KarenS CreditAttribution: KarenS commented#98 - you have to enable the 'Entity Tokens' module, as noted in the issue summary above. That is what creates the tokens that use '-'.
Comment #100
liquidcms CreditAttribution: liquidcms commentedyes, sorry... that is also enabled. and it is the latest since it comes with Entity API (which is latest -dev)
this screen mostly shows the issue: http://screencast.com/t/OJHvc9R2OFgo
perhaps interference with some other module? entity cache, entity translation?
Comment #101
yankozmo CreditAttribution: yankozmo commentedI have the impression the 7.x-2.3 release broke the functionality: I had it up and running, but after updating to 7.x-2.3, said tokens don't seem to be working any more.
YK
Comment #102
videographics CreditAttribution: videographics commentedWith 7.x-2.3 and Entity Tokens 7.x-1.0-rc1 I've got formatting options in the entity listing for 'Date created' and 'Date changed', but (similar to #100) I've get nothing for my date fields. Manually typing stuff like [node:field-class-date-time:value:custom:Y-m-d] doesn't work for me either.
I too remember this working at some point...
Comment #103
KarenS CreditAttribution: KarenS commentedEntity Tokens got broken by #1266688: Support microdata in date fields, I need to revert that. Please keep this issue focused on the Token module tokens. That is the 'token support' that we can't do until the token module is updated.
Comment #104
KarenS CreditAttribution: KarenS commentedI created a separate issue about problems with Entity Tokens at #1530042: Get Entity Tokens working. Let's keep this issue focused on getting Token module tokens working.
Comment #105
videographics CreditAttribution: videographics commentedThanks Karen! http://drupal.org/node/1530042 makes it real clear.
Comment #106
langworthy CreditAttribution: langworthy commentedWhat's the status of this issue? I found it after noticing that auto_nodetitle was not converting a date field to the proper timezone. Am I in the right place? :)
Comment #107
klonos#1058856: Entity tokens not created for multi-value fields got committed. The project page still states that "Token support is not working in D7" and points to this issue here and its summary. So, the part that says one should apply the patch in that issue should be updated.
I have gone through that issue and it states that it got fixed by a commit for #1356006: Fix entity property info of product / customer profile / line item reference fields (so the issue should not be present in Entitty API 7.x-1.0), but some users do report issues like #1440928: Entity tokens for multi-value fields produce a fatal error.
@KarenS: So, should we replace the section in the issue summary to point people to that issue instead?
Comment #108
kclarkson CreditAttribution: kclarkson commentedI am really confused by all of these cross posted issues.
So is the current issue summary up to date ?
Also seeming Date is in Core for D8 is there a way to escalate the issue ?
I would think that being able to use date tokens from a custom date field is a "huge" necessity.
Thanks again,
Comment #108.0
kclarkson CreditAttribution: kclarkson commentedFix typos
Comment #109
klonosAny update regarding this would be greatly appreciated. Especially if I could get some answers on my questions in #107, I could then update the issue summary.
Thanx in advance.
Comment #110
justdave CreditAttribution: justdave commentedSo since all the paths seem to lead to this ticket for people trying to get date tokens to look correct in email templates, this is probably the best place to share what I figured out in my email templates to make the dates look correct.
[node:field-date:value:custom:D, M j, Y]{{[node:field-date:value:custom:Hi]==0000?: - [node:field-date:value:custom:g:i A]}}{{[node:field-date:value:custom:YmdHi]==[node:field-date:value2:custom:YmdHi]?: to {{[node:field-date:value:custom:Ymd]!=[node:field-date:value2:custom:Ymd]?[node:field-date:value2:custom:D, M j, Y]{{[node:field-date:value2:custom:Hi]==0000?: - [node:field-date:value2:custom:g:i A]}}:[node:field-date:value2:custom:g:i A]}}}}
This uses medium date formats (Mon Dec 3, 2013 - 7:00 PM)
It leaves off the time and shows only the date for an all-day event. If leaves off the end time if there isn't one. It shows the date range for multi-day events. It leaves off the date and shows only the time on the end time if it's on the same day as the start time.
It doesn't show any timezones... on my site it was unneeded because it's for a local group where all members are guaranteed to be in the same timezone. It makes the horrible assumption that any date that's midnight is going to be an all-day date. This seems like a Bad Thing to me, but I couldn't figure out any other way to determine that.
Comment #111
Renee S CreditAttribution: Renee S commentedThanks, justdave, that's really helpful. AFAIK the "midnight" assumption is also baked into the "All day" checkbox in Date itself, so even if it's a Bad Thing, it's not unprecedented ;)
Comment #112
bmateus CreditAttribution: bmateus commentedFor those searching to just custom format your Date field on your emails using EntityForms with EntityNotifications, the token that worked for me was
[entity:field-date:custom:l, j F Y]
Using "value", as in
[entity:field-date:value:custom:l, j F Y]
didn't work at all.I guess I'm using Tokens only, since they have hifens instead of underscores (which should mean EntityTokens?).
Comment #113
mxhBy using the modules
creating a Date field of type Unix timestamp and setting up a rule, I'm (currently) able to format the date value with this token pattern:
Comment #114
stewart.adam CreditAttribution: stewart.adam commented#113 not working for me in the pathauto alias settings, using Date 7.x-2.8 and Entity 7.x-1.5. Date field is multi-value.Edit: Ignore above, managed to get it working with a combination of regular token and entity_token syntax:
[node:field-date:0:value:custom:Y-m-d]
works for a multi-valued date field.Comment #115
svogt0511 CreditAttribution: svogt0511 commentedRef above:
Edit: Ignore above, managed to get it working with a combination of regular token and entity_token syntax: [node:field-date:0:value:custom:Y-m-d] works for a multi-valued date field.
I used that to get it working, as well.
What was being displayed for replacement tokens for referencing the start/end dates in my date field was wrong. It took quite quite a bit of searching to come up with this solution.
Perhaps I have the wrong versions of modules. I am still fairly new to drupal.
Comment #116
BigBrother2010 CreditAttribution: BigBrother2010 commentedToken works but without "value" as part of the token for me. Still i cant get multi-value to display. I have 3 dates, but only first one is showing.
Comment #117
ShaneOnABike CreditAttribution: ShaneOnABike commentedI can confirm that this does work while it is not shown actually!
But just remember you need to use the selector node:::value:custom:
By item # I mean the date item in the array.
@KarenS: Can you document this on the front Date page or the README since I think it's fairly important for folks.
Comment #118
Christopher Riley CreditAttribution: Christopher Riley commentedI am noticing that it is giving the wrong date. I am thinking it is a timezone thing, suggestions?
Comment #119
alysaselby CreditAttribution: alysaselby commented#117 worked for me. Thanks this was the one combo I had not tried.
[node:field-date:0:value:custom:Y-m-d] works for a multi-valued date field
I should also add that for schema.org events I needed the start and end date to display separately in ISO format and this worked:
Start: [node:field-event-date:0:value:custom:c]
End: [node:field-event-date:0:value2:custom:c]
Comment #120
DamienMcKennaSo it looks like we need a documentation task rather than a critical bug report.
Comment #121
chicagomom CreditAttribution: chicagomom as a volunteer commentedAs #118, my experience is that token in format [node:field-date:0:value:custom:Y-m-d] gives output but is off by time zone difference (in my case, site regional timezone set to UTC-6 (Chicago), so an event on 8 Jan 7pm gets returned as 9 Jan 1am.
(7.x-2.10 doesn't do this.)
Comment #122
asb CreditAttribution: asb as a volunteer commentedNo luck to extract the year segment from a date field with something like
[node:field-release-date:0:value:custom:Y]
or[node:field_release_date:0:value:custom:Y]
.The only thing working is what the tokens browser is listing -
[node:created:custom:Y]
. Though, this syntax doesn't work either for date field values (e.g.[node:field_release_date:custom:Y]
).Using drupal core 7.61, 'date' 7.x-2.10, 'token' 7.x-1.7.
Tried to enable 'Entity tokens' from Entity API 7.x-1.9, but this breaks
./admin/structure/types/manage/…
.Considering the original topic of this issue - "Document how to use date tokens" from March 2011 -, could anyone please give a summary which version of which module is supposed to give which result?
Currently, trying to work with tokens is a bit like playing string lottery. You might win sometimes, but you need to play a looooot of combinations…
Thank you!
Comment #123
loudpixels CreditAttribution: loudpixels commentedIs it possible to use a date token with an offset? I'm trying to auto-generate a node title with tomorrow's date. something like: [date:long] + 1 day? Any help or pointers would be greatly appreciated.