Description:
Date [node:field-name-here:custom:?] tokens are not displaying correctly when used for automatic node titles. The titles using "Date tokens" are displayed -1 year from whatever date you selected on the node. So if you select 2011 in the node, and then save. You will see the token generated 2010 for the node title.
Installed Modules:
auto_nodetitle-dev-7.x-1.0
date-7.x-2.0-alpha3
Recreate Issue:
1. Create a new content type.
2. Add a date field to that content type. (Year, field_year, Date, Select List)
3. Configure automatic title generation for that content type. Check "Automatically generate the title and hide the title field". Use [node:field-year:custom:Y] as your "Pattern for the title".
4. Create a node for that content type. Select a "Year" value and save.
5. The date thats specified in the node is -1 year for the title. So if you selected 2011 it would show 2010 instead.
Comment | File | Size | Author |
---|---|---|---|
#49 | auto_nodetitle-custom-date-tokens-1197278-49.patch | 1.21 KB | kducharm |
Comments
Comment #1
NancyDruHow did you get it to even create a token for the new field?
Comment #2
MichelleI don't know if this should go in a new issue or not... I'm having issues with date tokens but not the same as yours.. If I put in just Y like you did, it correctly puts in 2011. I'm using a date field with a pop up calendar that has year, month, and day. So it seems to work with that setup. But trying to put F, Y or F Y or even 'F, Y' in there results in the token not being recognized.
Michelle
Comment #3
MichelleOh, duh, it just occurred to me that the ? might only be meant to replace one bit of the date. I put in two tokens, one for month, one for year and that works. So my problem might be by design...
At any rate, I am getting the correct date out of it so it may be particular to the widget you're using?
Michelle
Comment #4
droath CreditAttribution: droath commented@NancyDru - I did have a problem with the token not getting populated for the new field as well. After clearing my drupal cache, the token field populated in the token replacements.
@Michelle - It looks like we are having two different issues. I found out that the custom date token doesn't like spaces when using custom PHP date replacements. This seems to work though for me [node:field-YOUR_FIELD_NAME:custom:F,Y] I think your problem is related to the space issue, correct? When I use this custom date token [node:field-YOUR_FIELD_NAME:custom:F,Y] everything shows up correctly in the node title that's been created. It's only when I use [node:field-YOUR_FIELD_NAME:custom:Y] the year is -1 year from the year I selected.
EDIT: It only seem like this is an issue if the date "Granularity" option field is only set to "year".
Here is a screencast of this issue:
http://dl.dropbox.com/u/1211031/AutoNodeTitle-Date-Issue-1197278.mov
Comment #5
NancyDruNope, I am not getting fields to show up like you show in your screencast, but then mine are not dates, they are text. Yes, I have cleared the cache about a billion times working on a Calendar issue.
Comment #6
MichelleYeah, it's probably the space that's doing it.
Same here for me having to clear the cache before new field tokens will show up.
Michelle
Comment #7
NancyDruAs a matter of fact, I looked at the content type for one that has a date field and no tokens there either.
Comment #8
MichelleYou do have the Token module installed, right? That may sound silly but that tripped me up at first because, for some reason, I thought Token was part of core in D7.
Michelle
Comment #9
NancyDruYes, I have Token and Token Fields.
Comment #10
beckyjohnson CreditAttribution: beckyjohnson commentedI am having an issue as well, I am using a content token and it's generating everything a day behind the date I input.
My node title looks like this: [node:field-news-category] [node:content-type] [node:field-news-date:medium]
If I input my date as September 20 2010, the title generated says "September 19 2010".
....I can't see that it's a time zone issue either, i'm not using hour or minute increments.
Becky
Comment #11
MrPaulDriver CreditAttribution: MrPaulDriver commentedI am having a slightly different problem. I am trying to use a custom date token - exactly like at screencast #14.
When I select node tokens I find that the date token are not present. Just Date Changed and Date Created.
It's quite important to me, if anybody can put me right.
=====
EDIT
Have looked in to this further, the problem appears to be due to an issue in the token module together with a knock-on issue in the date module.
http://drupal.org/node/1103032#comment-4977086
Comment #12
swortis CreditAttribution: swortis commentedHas there been any updates on this issue? Date tokens still appear to be "one off" when used in the module, be it year, date, etc.
Comment #13
break9 CreditAttribution: break9 commentedI am having the exact same issue. the date displayed in the auto node title via tokens is one day before the date actual saved to the node.
Anyone have an answer?
Comment #14
rsgracey CreditAttribution: rsgracey commentedMy php god discovered the source of the issue. The date is always reading from the "long" date type. Whatever format you put into the Long will show up in the node title. It's a frustrating workaround, but you can at least have control over the date in your title.
Go to "admin/config/regional/date-time" and create the format to select in the Long format.
HTH,
Stephen
Comment #15
richardbporter CreditAttribution: richardbporter commentedSame issue here. Anyone have a workaround/patch for this?
Comment #16
scottrouse CreditAttribution: scottrouse commentedSame issue for me.
Just to clarify, I have a node with a "publication date" field. That is a date field with year, month, day granularity.
Tokens are used to construct the title for that node (with auto node title module), path (using pathauto), and breadcrumb (using custom breadcrumbs). The date is also displayed when that node is viewed.
If client selects a date, let's say 01/23/12, for that field, the date is displayed properly in the node's field and the path. It is, however, showing one day too early (1/22/12) for the node title (and, of course, the breadcrumb as it displays the node title).
Screenshot showing this behavior: https://skitch.com/scottrouse/8nt7y/autonodetitle-oboe
Comment #17
JonMcL CreditAttribution: JonMcL commentedThis is absolutely a timezone issue. If your date field is only using the year granularity, the raw data of the date is set for Jan 1 of that year at 00:00:00. So when timezone differences are applied, you end up back on Dec 31 of the year before.
In my case I'm using day granularity and when I test with 1998-01-01 (which becomes 1998-01-01 00:00:00), I end up with a title of "Wed, 12/31/1997 - 19:00" when I use the Entity Token value of [node:field-date-event:medium] for my title.
When I put that same token value in the body of my node, it correctly outputs: "Thu, 01/01/1998 - 00:00" (using the Token Filter module). My timezone is for NYC which is GMT -5.
So I haven't had time yet to figure out what auto_nodetitle is doing differently than token_filter, but if anyone is researching this, I would definitely look to timezone information not being set correctly somewhere in the call chain.
My solution is to set the site's default time zone (admin/config/regional/settings) to the UTC time zone and disable the option for users to set their own time zone. UTC just so happens to be the time zone of my production server anyway for this site.
Comment #18
grasmash CreditAttribution: grasmash commentedI'm experiencing this same issue, but I noticed an additional detail. When saving the node initially, the date is generated incorrectly. However, if you go to the 'find content' screen and use the 'update automatic node titles' action, the date will be corrected.
Comment #19
hosef CreditAttribution: hosef commentedI have also been plagued by auto_nodetitle changing my dates. It appears to change by 1 in whatever the smallest time value shown. I have a few other projects happening now, but I think I will start trying to debug this in the next week or two.
Comment #20
casey CreditAttribution: casey commentedauto nodetitle is generated during hook_submit() and hook_presave(), date fields are changed (see date_field_update_helper()) in date_field_insert/update during field_attach_insert/update() which is run after that.
#1509434: date_field_update_helper() is run to late
Comment #21
casey CreditAttribution: casey commentedAnother solution is to follow how node_preview() is doing it; call field load hooks. This also could fix yet unknown issues with other field types.
Comment #22
hosef CreditAttribution: hosef commentedOk, I was going to apply your patch, however I updated to the latest version of date and auto_nodetitle before doing it and my problem of the titles being off by one went away. So, I assume it is fixed, but I will wait for someone else to confirm before I change the status of this issue.
Comment #23
mollyavalon CreditAttribution: mollyavalon commentedI'm having almost the same problem. I just updated to the dev version in hopes it would be fixed, but no.
I'm using a date token that includes the time. The time displayed as the token in the nodetitle is 5 hours ahead of the time entered in the date field. Users may not set their own timezone, and I checked to make sure I have to correct time zone selected in the regional settings.
I tested the token in a view, and it displays correctly.
Comment #24
chiebert CreditAttribution: chiebert commentedI had the same problem of granularity (date field with granularity of Month) affecting auto node titles (timezone offset kicks back the date by a day, for me). This was running auto_nodetitle-7.x-1.0 and latest stable date-7.x-2.5 (which was released after #1509434: date_field_update_helper() is run to late was committed - see #20 above).
But the patch in #21 works for me, applied against auto_nodetitle-7.x-1.0. Worked on two sites, one running latest stable Date 7.x-2.5 , and another running earlier Date 7.x-2.2 (which was before #1509434: date_field_update_helper() is run to late).
Comment #25
rconstantine CreditAttribution: rconstantine commentedthe patch seems to work for me. i'm using dev version and date 2.5 - both for d7
Comment #26
twardnw CreditAttribution: twardnw commentedthe patch did nothing for me, the field I am trying to use for my title has date and time, using something like node:field_datetime:long results in a blank title.
Comment #27
brianbrarian CreditAttribution: brianbrarian commentedPatch from #21 works for me (Auto Nodetitle 7.x-1.0, Date 7.x-2.5).
I have the Entity Tokens module -- part of http://drupal.org/project/entity -- installed and am using that token format, which has dashes instead of underscores; e.g. [node:field-mydatefield:short].
Comment #28
dadderley CreditAttribution: dadderley commentedThanks @casey
I was having the same problem using this.
This is my configuration:
- Drupal core 7.16
- Automatic Nodetitles 7.x-1.0
- Date 7.x-2.6
- Entity API 7.x-1.0-rc3 (Entity tokens is a sub module)
I have a date field called "field-session-date".
This is shared between content types.
I have a custom date format set up.
"field-session-date" produces this token [node:field-session-date:custom:m/d/Y]
The auto node title produced was always off by one day.
When I bulk updated the automatic nodetitles ("update automatic nodetitles" action @ http://www.mysite.ca/admin/content), the date in the automatic nodetitles was corrected.
I applied the patch in comment #21 posted by casey on March 30, 2012 http://drupal.org/node/1197278#comment-5805310.
The problem seems to have gone away.
Now, Automatic Nodetitles is producing the right date based on the token.
Comment #29
Nathaniel CreditAttribution: Nathaniel commentedSimilar situation as #28, applying the patch in #21 fixes the issue.
Comment #30
Nikdilis CreditAttribution: Nikdilis commentedNote that it is possible to use the token in the following way in order to fix some of the issues above:
Comment #31
kclarkson CreditAttribution: kclarkson commentedI am confirming that the patch in #21 has fixed my automatic node title where it was one year less.
Can we get this committed ?
Comment #32
adam-delaney CreditAttribution: adam-delaney commentedsubscribing
Comment #33
RobertNelsonVance CreditAttribution: RobertNelsonVance commentedIs my issue the same thing, similar, or different?http://drupal.org/node/1917418
EDIT: Ok, nevermind. Patch in #21 worked for me.
Comment #34
steve.colson CreditAttribution: steve.colson commentedChiming in for a bump. Patch at #21 works great.
Comment #35
droath CreditAttribution: droath commentedI don't know if this module is well maintained anymore. So I wanted to let everyone know if they are having problems they could use "Automatic Entity Label" module instead. It's the same concept as Automatic Nodetitles, it just works with any entity instead of just nodes. It will even import your old automatic nodetitles configurations for you.
Comment #36
onejam CreditAttribution: onejam commentedThe patch in comment #21 works for me too for Auto Nodetitle 7.x-1.0. Thanks.
Comment #37
p0832414 CreditAttribution: p0832414 commentedThe patch in comment #21 worked for me aswell. You made my day :)
Comment #38
zooter626 CreditAttribution: zooter626 commentedAutomatic Entity Label works to solve the issue i had with auto_nodetitle, and it seems like i could do a lot more with it. Thanks for pointing this out!
Comment #39
agerson CreditAttribution: agerson commentedPatch #21 works for me as well. Lets get it committed.
Comment #40
mspano CreditAttribution: mspano commentedI change de format date, use "timestamp" instead "date". Solved for me.
Comment #41
vasna sdoeung CreditAttribution: vasna sdoeung commentedPatch #21 works! Someone commit it to repository.
Comment #42
jordan8037310 CreditAttribution: jordan8037310 commentedAgain, Patch #21 works, let's get this committed.
Comment #43
daveparrish CreditAttribution: daveparrish commentedI switched to Automatic Entity Label. It doesn't have this issue and it works well with features.
Comment #44
stephesk8s CreditAttribution: stephesk8s commentedPatch #21 worked for me also with 7.x-1.0+1-dev and Date 7.x-2.8.
Comment #45
bjcooper CreditAttribution: bjcooper commentedThe patch from #21 worked perfectly for me.
Comment #46
beeyayjay CreditAttribution: beeyayjay commentedPatch #21 worked perfectly for day of week ('D').
Comment #47
joelstein CreditAttribution: joelstein commentedI think all that's needed here is a re-roll against 7.x-1.x-dev. Here you go!
Comment #48
awolfey CreditAttribution: awolfey commented#47 works for me. Thanks @casey and @joelstein.
Comment #49
kducharm CreditAttribution: kducharm at CivicActions for Acquia commentedHere is a version that checks that $node->nid exists in the presave, since I was getting warnings when using Migrate module with the #47 patch.
Comment #50
joncjordan CreditAttribution: joncjordan commentedIs this patch getting committed?
Comment #51
smithmilner CreditAttribution: smithmilner as a volunteer commentedWe had issues with form values being overridden when loading field values like this. Easiest solution for us was to apply the loaded field values to a cloned node and then copy the title over.
Comment #52
markabur CreditAttribution: markabur commentedI was having trouble with the auto_nodetitle token returning the wrong date for a field set to month granularity.
The token for pathauto was working fine, but the token for auto_nodetitles was getting timezone-adjusted, which made the month off by one.
Tested #51 and it works for me. Thanks, all! This was driving me nuts!
Comment #53
jeffschulerPatch in #49 works well for me.
I believe we should continue to follow that path -- the one established in #21 and tested with much success already -- instead of the one proposed in #51.
Comment #54
jeffschuler@Donnyboypony sorry to short-change. I didn't look closely enough at what you were doing. Where are you seeing form values overridden? And why skip the change in presave?
Comment #55
smithmilner CreditAttribution: smithmilner as a volunteer commentedIf memory serves me. We had an issue where we couldn't manipulate og_group_ref fields. Loading the field values like this overrides the field change. My proposed change was to simply load the field data on a cloned node and copy the title over.'
I didn't mean to skip the presave. I made a mistake.
Comment #56
dhansen CreditAttribution: dhansen at Sevaa Group commentedReviewing #49:
We need the same check for NID here that we have on the presave, or you get an error when creating new nodes that have auto_nodetitle.
Comment #57
manish-31 CreditAttribution: manish-31 at OpenSense Labs for DrupalFit commented@NancyDru install latest version of token module and click on "Browse available tokens", while creating content type, you will be able to get token for a field.
@droath the date shown in the title is correct, however 00:00:00 gets added, actually this is coming due to date module it returns date string we need to convert it into date object and then fetch year from that. Here custom php code feature saves us (that's why this feature is added).
In order to achieve that please write the following code in the textarea "Provide php pattern" :
By writing above code and checking "Execute PHP in pattern". You will be able to get year in the title.
Comment #58
gaurav.kapoor CreditAttribution: gaurav.kapoor commented