I have a custom date field that I was displaying like this:
[node:field_show_date:custom:M]
and [node:field_show_date:custom:j]
This was working fine showing Month and day.
"field_show_day" is my custom field as listed under the node tokens.

I updated may CTools and Date Modules and now this doesn't work.

Comments

broeker’s picture

Did you ever solve?

I just updated CTools, Views, and Date also and my custom formatters are no longer working; they just display the raw token.

Unfortunately I'm not sure which of these three updates blew up the custom formatters but something definitely went wrong.

bcobin’s picture

Priority: Normal » Critical

Same problem here. Marking this critical because it breaks Custom Formatters entirely, for custom dates anyway. Yikes!

Update: I've opened up the following issue in case it's the recent Token upgrades that are causing CF to break here. Insofar as there haven't been any changes to CF, I think it's at least worth looking into.

http://drupal.org/node/1536776

kruser’s picture

it seems like there is something up with Entity tokens - http://drupal.org/node/1103032

Deciphered’s picture

Status: Active » Postponed

Field Tokens are pretty neutered, I'm rather annoyed about it really, and will try to improve the situation when I have time, but currently, at least with just the standard modules, those tokens don't exist.

I did commit a patch recently to make unprocessed tokens disappear, but that's not really going to help here.

Deciphered’s picture

Status: Postponed » Active

So I spent some time in the last couple days after the 7.x-2.1 release researching the Token debacle and working on improving Token support,

Basically what I could see is that while Token had a good solution for chained Field tokens it never made it farther than a patch and doesn't look like it ever will, Custom Formatters did support the method as did other modules, I believe the Date module was one of those modules.

As an alternative, the Entity tokens module does have support for chained Field tokens, it's an alternative approach, and while I don't like it quite as much it does seem to work well enough. I have committed support for the Entity tokens module Field Tokens in the latest development release.

Unfortunately there are still issues, when using both Token and Entity tokens you will have duplicated fields, one version with underscores and one version with dashes, this is due to a disagreement between the two module maintainers and you have to specifically chose the dashed items to leverage the chaining. And from my own personal experiences with running the two modules together, there will likely be other issues that will pop up.

You can use just Entity Tokens, but the Token module does provide the Token Tree for browsing tokens, so it's a bit hard to not have it available.

Either way, Custom Formatters does support the available Token methods (that I'm aware of) so if this doesn't fix it I would suspect that the issue lies with one or a combination of the other modules involved, but I am happy to try to get this issue resolved.

bcobin’s picture

Latest dev version works - thanks SO much, @Deciphered! In my case, I exported a variation of a Custom Formatter I had used on another site and once I changed the parameters from Date (ISO) to Date and entered the tokens with the dash, it worked like a charm.

Thank you very much for taking the time with this - doesn't sound like it was much fun. Greatly appreciated... really.

Deciphered’s picture

Status: Active » Fixed

Glad I could help.

I'm still not exactly happy with the current Token integration, but it'll do for the moment until I have time to push it further. My thoughts are that I might have to create another contrib module called 'Field Tokens' to get exactly what I want, but hopefully it doesn't need to come to that.

For the moment, marking this as fixed and the current functionality should be released for 2.2 within a few days (if all goes well).

Cheers,
Deciphered.

Status: Fixed » Closed (fixed)

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

bcobin’s picture

Status: Closed (fixed) » Active

Reopening this - in the latest 2.2 versions, this seems to be broken again. (It did work for a while - I swear!)

In my case, the CCK field is field_published_date - [node:field_published_date:custom:M], for example is no longer recognized (with either dashes or underscores) nor does any "custom" variation appear as an option as an available token. At one point, there were two options, one with dashes and one with underscores; now only the basic option appears.

I did several module updates (including this one), so this was possibly caused by an update to Entity API (I'm now using rc3); I would happily roll back if I could be sure what to roll back to. Is there an earlier dev version I could try?

Thanks for your help here and all the work you've done @Deciphered - it's frustrating that this was broken for so long, fixed (hooray!) and then broken again! Not your fault I'm sure, but any guidance is greatly appreciated - thank you!

Deciphered’s picture

Hi bcobin,

It's very possible that this is somewhat my fault, in 2.2 I opted to remove support for the never committed field token patch, which I suspect that Date is still using. Unfortunately there doesn't seem to be much of a consensus at the moment on field tokens, so I opted to go for Entity tokens support as it is at least committed.

I know this isn't exactly the answer you wanted, and I'm sure you're as disappointed as I am about the situation, chained field tokens are one of the things I was excited about in D7...

I'll mark this as postponed for the moment, and hopefully in the future it can be resolved correctly.

Cheers,
Deciphered

Deciphered’s picture

Status: Active » Postponed

Forgot to change status

bcobin’s picture

Thanks @Deciphered for the explanation and prompt reply - good to know I'm not losing my mind! (Not about this, anyway.)

So let me see if I've got this right: Custom Formatters is dependent on other modules for Tokens and the "custom" option for Date Tokens isn't provided by Entity API. Date provides the "custom" option for Date tokens, but only via a patch, which insofar as it hasn't been committed, could go away at any time. So to be safe, you're not supporting Date tokens.

Current date (which is system-generated) has a "custom" option, but that's apples and oranges. So until Entity decides to generate date tokens with a "custom" option, we're out of luck. How am I doing so far?

Anyway, I'd be happy to use the earlier version you had and then go to 2.2 if things change either on the Date or Entity side - will 2.1 work for me? I don't see where I can find earlier dev versions (I still totally don't understand .git.)

Sorry to bug you - thanks for your help!

Deciphered’s picture

Title: Custom Formatter for custom date field no longer interpreted » Fix Token engine
Issue summary: View changes

The Token engine not working, and in some part field tokens in Drupal, has been one of my biggest annoyances.

I need to revisit this and make it work!

(p.s, Sorry I never answered your question @bcobin, it's probably much too late now).

bcobin’s picture

Thanks, @Deciphered - better late than never, I suppose!

I did end up getting things to work, and with current production versions of modules, evidently, although I don't remember the details!

But CF seems to be happily working for what I wanted it for; namely, displaying dates in a little calendar icon.

Thanks for getting back and, of course, thanks for the module!

Deciphered’s picture

Status: Postponed » Active

Most, if not all, issues with the Token engine should be resolved with the use of the new Field Tokens module I have just released.

It add's Field property tokens to all field types, giving access to raw field property values, such as 'uri' on an Image field or 'timezone' on a date field and so on. It also allows specification of the delta for multifield values.

And in the case raw data isn't ideal (in the case of date fields), you can use the other type of token it provides, formatted fields, which allows the data to be passed through another existing formatter with specified formatter settings, which means you should be able to achieve pretty much any required result.

Leaving issue as Active for a while so I can do some further testing, but I think this is the best solution.

Deciphered’s picture

Another major improvement pushed for Entity tokens integration, which while not the most user friendly approach (as Struct tokens don't really provide proper examples) it makes things a lot more usable, and is better than the Field property tokens.

As such, if you wanted to get an Image fields file url you would use the following token in you HTML/Token formatter: [struct:file:url]

Not the most obvious token name, but it works and you don't need to worry about specifying deltas as each item is processed separately.

Will have to add some documentation and examples.

Deciphered’s picture

Status: Active » Fixed

And again. This time Entity Tokens module integration is working wonders, the [struct] tokens are still available, but the field tokens are now correctly chained.

If you are using a Image field you will be able to use [file] tokens, if you are using a Date field you will be able to use [date] tokens, and you will see the available tokens in the Token tree.

The tokens originally reported not working in this issue will work now, but even better, you would use [date:custom:M] instead so you are talking to the current field item.

Marking this issue fixed.

Status: Fixed » Closed (fixed)

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