The tokens created by Token module are not working for Date or other fields. But we had tokens created by the Entity Token module working at one point.

That got broken by a patch I committed before it was ready at #1266688: Support microdata in date fields. That patch is reverted but I'm still seeing problems. Not all my date fields seem to have tokens, only a few of them.

Not sure yet what the problem is.

Comments

karens’s picture

Status: Active » Fixed

OK, Entity Tokens work fine, but only when you use the latest dev version of Entity. The patch to get this working went in last November, but there hasn't been a release since before it was added. So tokens won't work unless you have the dev version.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bcobin’s picture

See http://drupal.org/node/1511830 - latest dev version of Entity API (4/23/12) doesn't fix the problem.

Taxoman’s picture

Status: Closed (fixed) » Active

Re-opening per #3.

linneawilliams’s picture

Status: Active » Closed (fixed)

Latest dev version of Entity and all most recent releases (as of today: 5/22/2012) of relevant modules have fixed this problem for me.

nickbits’s picture

Status: Closed (fixed) » Active

I may be missing the point, but I have all the latest dev releases (entity, date, token, etc.) and I don't get all of the tokens working. One example:

meetings/[node:field-event-date:custom:Y]/[node:title]

So question is is this fixed? Is it a date issue or are we still waiting for tokens (entity) to be fixed?

jeremymcminn’s picture

I would also like to know if this is working too

stevep’s picture

Working for me, but it wasn't initially.

Until I noticed I had not enabled Entity Tokens module, then ran cron and flushed caches, then the second "Date & Time [node:field-datetime:?]" selection in the replacement patterns (URL aliases) was available.

Then my replacement event pattern "event/[node:field-datetime:value:custom:j]-[node:field-datetime:value:custom:M]-[node:field-datetime:value:custom:Y]/[node:title]" worked fine. (my "node: field-datetime" might be different for others. Depends what you label it).

After that I updated the url's for existing events, as you would expect -- all good.

update -- just noticed the error in nickbits query.

I used [node:field-datetime:value:custom:Y] with "value" included. Works fine.

tim.plunkett’s picture

Status: Active » Fixed

Yes, using the dev versions and clearing the cache works just fine.

matmasr’s picture

stevep, tim.plunkett

Can you please let me know what exact versions of the DATE, ENTITY API and TOKEN you are using?

I am trying to create a custom formatter for a date field in my content type called "field_time" with an underscore. The date format for this field is ISO format. The Entity Token module shows me a token replacement called

[node:field-time:?]

I created at replacement token for my custom formatter as follows

<p>[node:field-time:value:custom:Y]</p>
<p>[node:field-time:value:custom:D]</p>
<p>[node:field-time:value:custom:j]</p>
<p>[node:field-time:value:custom:M]</p>

However, when I try to test it I get the following error

Fatal error: Call to a member function value() on a non-object in .........\Sites\mysitename\sites\all\modules\entity\entity_token.tokens.inc on line 297

I am using the following versions

DATE: 7.x-2.5
ENTITY API and ENTITY TOKEN: 7.x-1.0-rc3
TOKEN: 7.x-1.1

Thanks for your help.

matmasr’s picture

Follow up on the issue above. My date field is in ISO format. It is like that since I upgraded from D6 to D7.

nickbits’s picture

Reply to #8, sorry that was a typo, on autopilot. I will try a fresh install of drupal and see if it works, seems it is working for others, so obviously something on my set-up.

nickbits’s picture

Can confirm it is working for me on a fresh install. Not sure what the issue was previously. Just for reference, working installation using:

  • Drupal 7.14
  • Date (7.x-2.5+9-dev)
  • Entity (7.x-1.0-rc3+0-dev)
  • Token (7.x-1.1+0-dev)

Last 3 are the latest dev releases as of 3rd June 2012.

Thanks,
Nick

matmasr’s picture

Does anyone know why I could be getting this error ?

Fatal error: Call to a member function value() on a non-object in .........\Sites\mysitename\sites\all\modules\entity\entity_token.tokens.inc on line 297

I am using the following versions

DATE: 7.x-2.5
ENTITY API and ENTITY TOKEN: 7.x-1.0-rc3
TOKEN: 7.x-1.1

I am guessing it has to do with ISO date formats. When I created a new DATE field and applied my formatter with the following tokens it is working fine.

Thanks

bforchhammer’s picture

Status: Fixed » Active

Sorry for reopening, but I'm getting this error as well.

I have a date-field which allows multiple values. Verified this on a clean drupal install with latest version of drupal, and latest dev versions of date and entity.

Steps to reproduce:

  • Create a new "Date" field field_multiple_dates
  • On field settings:
    • change "Number of values" to "Unlimited"
    • Tick "Collect an end date"
  • Create a node, enter at list one date (one is enough for things to "break")
  • Test the [node:field-multiple-dates] token

Tokens results:

  • [node:field-multiple-dates] = "Property 0"
  • [node:field-multiple-dates:value] => Fatal error: Call to a member function value() on a non-object in \sites\all\modules\entity\entity_token.tokens.inc on line 297
tim.plunkett’s picture

Status: Active » Closed (fixed)

Please open a separate support request.

kurtronaldmueller@gmail.com’s picture

has anybody found a way to do this without a fresh install of Drupal? I have a site with a good amount of content that makes migrating a pain... perhaps somebody could point me to a module that would make it easy to migrate? Would backup & migrate and the migrate module take care of this? Please let me know.

Kurt

colan’s picture

I was able to get it working without a fresh installation. It was necessary to drop the ":value" part of the string. Here's an example:
[node:field-date-effective:custom:Y-m-d\TH:iP]

nodecode’s picture

So was this committed to the latest release? I'm getting this same error using 7.x-2.6 and 7.x-dev even after clearing all caches etc. It's not working for me, and furthermore I contend that a fresh Drupal install is NOT a solution.

That said, this bug may have roots not in the Date API but in the Entity API module as pointed out in #17 So I believe this issue may not be fixed until #1621084: Support list<struct> type tokens is fixed. I'll be watching that issue.

kclarkson’s picture

So with the patch #1621084 applied to the Entity API will I be able to use the custom token's of [node:field-time:value:custom:Y] ?

Thanks,

bomarmonk’s picture

I'm still getting the error where date tokens (for entities/ date fields) returns a date earlier than the one entered. For example, I put in [node:field-date-issue-year:custom:Y], and even though the field accurately reflects the year entered (showing 2013), the date token subtracts one year (showing 2012).

I'm using Token 7.x-1.4, Date 7.x-2.6+2-dev, Automatic Nodetitles 7.x-1.0, and Drupal 7.18. Is there a way to get the date entity token to return the right date?

I'm starting a new issue, since I'm not sure my problem is the same as the one being addressed here.

bomarmonk’s picture

Also note that I'm using Entity API version 7.x-1.0 (released December 25 2012)

bcobin’s picture

@kclarkson - #21

I have custom dates working with the dev version of Entity API (7.x-1.0-rc3+11-dev) and the latest production release of Custom Formatters. No patching required. Just make sure to clear caches, I guess. I've run into another issue with Entity API where the dev version fixed things - for @bomarmonk, I'd suggest using the latest dev and see what happens.

rockland’s picture

Subscribing

kclarkson’s picture

@bcobin

Thanks for the suggestion

bcobin’s picture

Status: Closed (fixed) » Active

This is broken - again - with latest dev of Entity. I note discussion of microdata in other threads, along with patches, but am at a loss here.

Custom formats are available for current date field, but not for custom fields - any clarification as to what the issue is would be greatly appreciated...

kclarkson’s picture

@bcobin

doesn't look like your solution is working either. I am trying to get a url based of off a node date field. So I have a start and an end date. I would like the url alias to be 2013/03-01/node title

klonos’s picture

vijaycs85’s picture

Anyone still facing this problem?

vijaycs85’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)

#15 is #1618200: Fix date tokens for multiple values (fatal php error)
#27 and #28 are showing that this is more of entity than date.

Closing this issue now.

vijaycs85’s picture