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.
In D7, we have the token API in core, and core also provides a 'date' token type. All you need to do is to provide a raw-timestamp and and core allows users to use a 'custom' token like [node:field-date:custom:Y]. The current token implementation looks like its the D6 version so may cause problems. I'll look into getting this up to shape for Date's D7 version.
Comment | File | Size | Author |
---|---|---|---|
#11 | 906622-11-begin-work-on-date-tokens.patch | 10.61 KB | bfroehle |
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedThat would be great! I haven't had time to look at what has changed in Token.
Comment #2
scotwith1t+1 for token support. seems token has started to stabilize quite a bit. thanks dave and karen, you guys are amazing drupal rockstars. i promise one day soon i am going to learn to code and start helping you guys out some!
Comment #3
rosborn CreditAttribution: rosborn commentedI don't want to seem like I'm pressurizing because I know how hard everyone is working, but is this likely to make it into the module by the time Drupal 7 is released? Thanks for getting the Date Module working so well. I couldn't develop my site in Drupal 7 without it.
Comment #4
KarenS CreditAttribution: KarenS commentedIt will not make it in unless someone makes a patch. If this is important to you, make a patch. If you don't know how to do it, find someone who does.
Comment #5
andypostWhat kind of integration should be minimal enough to be implemented? I can make it but see no idea hot tokens should operate
Comment #6
LSU_JBob CreditAttribution: LSU_JBob commentedsubscribed. I really need this so I will try and look into the code and get a patch going.
Comment #7
dboulet CreditAttribution: dboulet commentedHas anybody here done enough work on this to post a patch?
Comment #8
dboulet CreditAttribution: dboulet commentedWondering: would this feature depend on the field tokens provided by Token module? See: #691078: Field tokens.
Comment #9
kbond CreditAttribution: kbond commentedSubscribe
Comment #10
bfroehle CreditAttribution: bfroehle commented~
Comment #11
bfroehle CreditAttribution: bfroehle commentedAs a start, we'll need to put the token code in
date.tokens.inc
to conform with the autoload functionality of system_hook_info().As @Dave Reid said, we'll want to take advantage of the existing 'date' token type in core (in system.tokens.inc). This means that we should completely remove date_token.inc and create a new date.tokens.inc.
I've attached a patch which provides date tokens for all date fields. The patch requires the most recent field tokens patch in #691078-92: Field tokens. Additionally, it will require a fix to #1067886: DateObject cannot handle UTC timezone with Unix datestamp before it will work for datestamp fields.
Example replacement token codes are
Comment #12
rhlowe CreditAttribution: rhlowe commentedSubscribing
Comment #13
KarenS CreditAttribution: KarenS commentedCommitted this much. You can provide another patch if you have more to add.
Comment #15
mrfree CreditAttribution: mrfree commentedthe committed patch doesn't work here... reading the code I noticed that the suggested
[node:field-xxx:date:medium]
syntax causes the variable$type = 'node'
so the if conditionif (($type == 'date-field-value') && !empty($data['item']))
is always false and however the array$data
doesn't contain any 'item' key but only a 'node' key.Can you please explain the code meaning? :)
Comment #16
bfroehle CreditAttribution: bfroehle commentedAre you sure you have that installed?
Comment #17
mrfree CreditAttribution: mrfree commentedYup, I've already applied the patch and a lot of new field related tokens are available now but using
[node:field-xxx:date:medium]
results in$type=node
in your function so all your code is simply skipped... or I simply haven't understand how it works yet :)Comment #18
hefox CreditAttribution: hefox commentedThe token support was temporarily removed in #1103032: Document how to use date tokens.
Note that I only figured this out after 3? 4? hours of trying to get token support to work after seeing this issue that seemed to indicate that it was partially working. Then I looked at the first patch, realized it didn't match the code, and went to repository viewer and saw about that issue.
Comment #19
mrfree CreditAttribution: mrfree commenteds**t!
many thanks hefox, reverting the patch http://drupal.org/files/issues/date-1103032-29.patch do the trick now the bfroehle's patch works
Comment #20
bfroehle CreditAttribution: bfroehle commentedOkay, so this is fixed then.