Download & Extend

Get Entity Tokens working

Project:Date
Version:7.x-2.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active

Issue Summary

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

#1

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.

#2

Status:fixed» closed (fixed)

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

#3

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

#4

Status:closed (fixed)» active

Re-opening per #3.

#5

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.

#6

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?

#7

I would also like to know if this is working too

#8

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.

#9

Status:active» fixed

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

#10

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.

#11

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

#12

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.

#13

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

#14

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

#15

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

#16

Status:active» closed (fixed)

Please open a separate support request.

#17

#18

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

#19

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]

#20

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.

#21

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,

#22

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.

#23

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

#24

@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.

#25

Subscribing

#26

@bcobin

Thanks for the suggestion

#27

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...

#28

@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

nobody click here