I created a test event with a Start Date and End Date of May 17 2008 and the path generated is Some-Domain-Name.tld/events/1969/12/31/some-event

The Pattern for all Event paths is events/[eventyyyy]/[eventmm]/[eventdd]/[title-raw].

I am on Drupal 6.2 using Event Module 6.x-2.x-dev

CommentFileSizeAuthor
#25 event_tokens.patch673 bytesclaudiu.cristea

Comments

greenskunk’s picture

I just noticed that I am using the 6.x-2.x-dev (2008-May-01) version. I am going to upgrade to the 2008-May-07 version and post my results.

greenskunk’s picture

Well, the Calendar link at the bottom of the event listing is correct but the Path Alias is not correct.

Example:

URL: Some-Domain-Name.tld/events/1969/12/31/womens-health-day
Women's Health Day
Please join us as we celebrate women!
Tagged: Health Department
Calendar (links to /event/2008/05/12)

I am going to test this on another server.

killes@www.drop.org’s picture

Status: Active » Postponed (maintainer needs more info)

I guess this needs pathauto to replicate?

I've tried a fix please get revision 1.371 and try if it is fixed.

korayal’s picture

I'm using 6.x-2.x-dev (2008-May-09) and still having the same problem.
Also another problem I have is when I try to set the dates;

start date: 05.10.2008 21:00
end date: 05.11.2008 01:00

and post the node, then when I edit the node the end date becomes "05.11.2008 00:00"

killes@www.drop.org’s picture

6.x-2.x-dev (2008-May-09) is not specific enough, please look at the second line of the module

korayal’s picture

it says;

// $Id: event.module,v 1.371 2008/05/08 23:03:21 killes Exp $

killes@www.drop.org’s picture

Which modules do I need to replicate this? pathauto + token?

korayal’s picture

tested v1.372, still no change.
I don't know much about the coding part, but I can say that it was working OK when I posted a node on 04/19/2008 (mostly i update to the most recent -dev modules on a daily basis)

greenskunk’s picture

Yes Pathauto and Token. I just tried out the following:

  • Event 6.x-2.x-dev // $Id: event.module,v 1.372 2008/05/09 14:36:53 killes Exp $
  • Pathauto 6.x-1.x-dev (2008-05-12) // $Id: pathauto.module,v 1.107 2008/05/10 20:27:59 freso Exp $
  • Token 6.x-1.10 // $Id: token.module,v 1.7.4.5 2008/01/29 15:12:19 eaton Exp $

I'll update Token tomorrow to the latest dev release.

Freso’s picture

@GreenSkunk (and others with the problem): Were you able to reproduce the issue on another server? Is the time/date consistent, or does it change according to the date/time you enter (or enter it at)?

Freso’s picture

Also, just to rule out (or not) the problem, could you try with Pathauto 6.x-1.0 (`cvs up -dP -r DRUPAL-6--1-0` - and `cvs up -dPA` to return to HEAD)?

killes@www.drop.org’s picture

Maybe it would be helpful to add some debugging into the function event_token_values.

The function should look like this afterwards:

/*
* Implementation of hook_token_values()
*/
function event_token_values($type, $object = NULL) {
if ($type == 'node') {
watchdog('debug', 'node passed into event_token_values '. serialize($object));
// Get the event start time as a Unix timestamp
$eventstart = $object->event['start'];
watchdog('debug', 'start time in event_token_values '. serialize($eventstart));
$eventstart = strtotime($eventstart);
watchdog('debug', 'unix start time in event_token_values '. serialize($eventstart));

$tokens['eventyyyy'] = date('Y', $eventstart);
$tokens['eventmm'] = date('m', $eventstart);
$tokens['eventmon'] = date('M', $eventstart);
$tokens['eventdd'] = date('d', $eventstart);
$tokens['eventday'] = date('D', $eventstart);
$tokens['eventweek'] = date('W', $eventstart);
watchdog('debug', 'results in event_token_values '. serialize($tokens));

return $tokens;
}
}

Please post the messages this generates after creating a new node.

greenskunk’s picture

I apologize for the late reply.

node passed into event_token_values

Type debug
Date Thursday, May 22, 2008 - 14:22
User webmaster
Location http://some.tld.org/drupal/?q=node/add/event
Referrer http://some.tld.org/drupal/?q=node/add/event
Message node passed into event_token_values O:8:"stdClass":43:{s:3:"uid";s:1:"1";s:7:"created";i:1211466136;s:4:"type";s:5:"event";s:8:"language";s:0:"";s:7:"changed";i:1211466136;s:5:"title";s:32:"Creekside's Family Fun Game Show";s:4:"body";s:83:"

Creekside Roundup's Equestrian events are a great time for the whole family.
";s:6:"format";s:1:"1";s:8:"revision";i:0;s:3:"log";s:0:"";s:4:"name";s:9:"webmaster";s:4:"date";s:0:"";s:6:"status";i:1;s:7:"promote";i:1;s:6:"sticky";i:0;s:2:"op";s:4:"Save";s:6:"submit";s:4:"Save";s:7:"preview";s:7:"Preview";s:13:"form_build_id";s:37:"form-70a6963f6f0c2e066c24120b373b0f80";s:10:"form_token";s:32:"1ad360764aae6c053054ebd73e2b389c";s:7:"form_id";s:15:"event_node_form";s:4:"book";a:13:{s:9:"menu_name";s:0:"";s:4:"mlid";N;s:3:"nid";s:3:"new";s:11:"router_path";s:6:"node/%";s:12:"has_children";i:0;s:7:"options";a:0:{}s:6:"module";s:4:"book";s:12:"original_bid";i:0;s:18:"parent_depth_limit";i:8;s:4:"plid";i:-1;s:6:"weight";s:1:"0";s:3:"bid";s:1:"0";s:9:"pick-book";s:36:"Change book (update list of parents)";}s:7:"comment";s:1:"0";s:5:"event";a:7:{s:8:"has_time";i:1;s:12:"has_end_date";i:1;s:14:"start_exploded";a:6:{s:5:"month";s:2:"05";s:3:"day";s:2:"25";s:4:"year";s:4:"2008";s:4:"hour";s:2:"10";s:6:"minute";s:1:"0";s:4:"ampm";s:0:"";}s:12:"end_exploded";a:6:{s:5:"month";s:2:"05";s:3:"day";s:2:"25";s:4:"year";s:4:"2008";s:4:"hour";s:2:"21";s:6:"minute";s:1:"0";s:4:"ampm";s:0:"";}s:8:"timezone";s:3:"479";s:12:"start_in_dst";i:1;s:10:"end_in_dst";i:1;}s:4:"menu";a:13:{s:4:"mlid";i:0;s:6:"module";s:4:"menu";s:6:"hidden";i:0;s:12:"has_children";i:0;s:10:"customized";i:0;s:7:"options";a:0:{}s:8:"expanded";i:0;s:18:"parent_depth_limit";i:8;s:10:"link_title";s:0:"";s:6:"parent";s:15:"primary-links:0";s:6:"weight";s:1:"0";s:4:"plid";s:1:"0";s:9:"menu_name";s:13:"primary-links";}s:9:"nodewords";a:2:{s:11:"description";s:0:"";s:8:"keywords";s:0:"";}s:4:"path";s:0:"";s:22:"pathauto_perform_alias";i:1;s:9:"old_alias";N;s:8:"taxonomy";a:1:{i:2;a:0:{}}s:6:"upload";s:0:"";s:6:"attach";s:6:"Attach";s:6:"teaser";s:83:"

Creekside Roundup's Equestrian events are a great time for the whole family.
";s:9:"validated";b:1;s:6:"is_new";b:1;s:9:"timestamp";i:1211466136;s:8:"moderate";i:0;s:4:"tnid";i:0;s:9:"translate";i:0;s:3:"nid";s:2:"34";s:3:"vid";s:2:"38";s:10:"build_mode";s:12:"token_values";s:7:"content";a:3:{s:6:"#title";N;s:12:"#description";N;s:8:"#printed";b:1;}}
Severity notice
Hostname 10.221.58.9
Operations

start time in event_token_values

Type debug
Date Thursday, May 22, 2008 - 14:22
User webmaster
Location http://some.tld.org/drupal/?q=node/add/event
Referrer http://some.tld.org/drupal/?q=node/add/event
Message start time in event_token_values N;
Severity notice
Hostname 10.221.58.9
Operations

unix start time in event_token_values

Type debug
Date Thursday, May 22, 2008 - 14:22
User webmaster
Location http://some.tld.org/drupal/?q=node/add/event
Referrer http://some.tld.org/drupal/?q=node/add/event
Message unix start time in event_token_values b:0;
Severity notice
Hostname 10.221.58.9
Operations

results in event_token_values

Type debug
Date Thursday, May 22, 2008 - 14:22
User webmaster
Location http://some.tld.org/drupal/?q=node/add/event
Referrer http://some.tld.org/drupal/?q=node/add/event
Message results in event_token_values a:6:{s:9:"eventyyyy";s:4:"1969";s:7:"eventmm";s:2:"12";s:8:"eventmon";s:3:"Dec";s:7:"eventdd";s:2:"31";s:8:"eventday";s:3:"Wed";s:9:"eventweek";s:2:"01";}
Severity notice
Hostname 10.221.58.9
Operations

Testing on another server

I'll test on another server today.

I don't use CVS so I am still using the same setup on the dev server as in post #9

greenskunk’s picture

Moved the current setup to another test server and ... it works!

Something must be wrong on my dev server.

I'd like to find out what could be doing this though.

greggles’s picture

Title: Incorrect Path Alias generated » Event Tokens Not Working Consistently - Incorrect Path Alias Generated
Component: Basic Event » Code

Updating title to be a little more accurate.

principessaDS’s picture

I was running into this issue as well, with

Events // $Id: event.module,v 1.373 2008/05/17 21:44:26 killes Exp $
Tokens // $Id: token.module,v 1.7.4.5 2008/01/29 15:12:19 eaton Exp $
Pathauto // $Id: pathauto.module,v 1.100 2008/04/28 19:47:10 greggles Exp $

I used Killes' #12 post as as starting point, and found that
$eventstart = $object->event['start'];
was the issue - it looks like it has been replaced by $object->event['start_exploded'];.

So my event_token_values now looks like this:

function event_token_values($type, $object = NULL) {
  if ($type == 'node') {
    // Get the event start time as a Unix timestamp
    //$object['start'] string (?) changed to $object['start_expoded'] (array)
    $eventstart = $object->event['start_exploded'];
    //$eventstart = strtotime($eventstart);
    //format hour
    $hour = _event_hour_to_ampm($eventstart->hour);
    
    $start = mktime  ($hour, $eventstart['minute'], $eventstart['second'], $eventstart['month'], $eventstart['day'], $eventstart['year'], $object->start_in_dst );

    $tokens['eventyyyy'] = date('Y', $start);
    $tokens['eventmm']   = date('m', $start);
    $tokens['eventmon']  = date('M', $start);
    $tokens['eventdd']   = date('d', $start);
    $tokens['eventday']  = date('D', $start);
    $tokens['eventweek'] = date('W', $start);

    return $tokens;
  }
}

Seems to work thus far for me. The bugaboos here are

  • I haven't properly delved into the code to find the ins & outs of timezone handling.
  • I use 24 hr display time, so I'm not sure if the _event_hour_to_ampm addition is correct
Equ’s picture

Have the same problem. The solution provided by principessaDS doesn't work for me. Are there any other ways of solving this issue? Thanks!

greenskunk’s picture

Once again I have the same problem but now it is on the host that it did work on.
I'm now using:
- Drupal 6.3
- Date 6.x-2.0-beta4 // $Id: date_api.module,v 1.64.2.5.2.24 2008/08/01 20:08:09 karens Exp $
- Event 6.x-2.x-dev (2008-Jun-30) // $Id: event.module,v 1.380 2008/06/30 22:12:17 killes Exp $
- Pathauto 6.x-2.x-dev (2008-Aug-04) // $Id: pathauto.module,v 1.119 2008/06/24 17:13:51 greggles Exp $
- Token 6.x-1.x-dev (2008-Jul-23) // $Id: token.module,v 1.7.4.8 2008/07/14 19:15:10 greggles Exp $

Going to start debugging.

greenskunk’s picture

I modified the file event.module function event_token_values to get it to work.

I can confirm principessaDS findings in that $object->event['start'] is now $object->event['start_exploded']

I only had to change two lines after checking everything out.

function event_token_values($type, $object = NULL) {
  if ($type == 'node') {

    // Get the event start time as a Unix timestamp
    //$eventstart = $object->event['start'];
    $eventstart = $object->event['start_exploded'];

    //$eventstart = strtotime($eventstart);
    $eventstart = strtotime($eventstart['year'] . "-" . $eventstart['month'] . "-" . $eventstart['day'] . " " . $eventstart['hour'] . ":" . $eventstart['minute'] . ":00");

    $tokens['eventyyyy'] = date('Y', $eventstart);
    $tokens['eventmm']   = date('m', $eventstart);
    $tokens['eventmon']  = date('M', $eventstart);
    $tokens['eventdd']   = date('d', $eventstart);
    $tokens['eventday']  = date('D', $eventstart);
    $tokens['eventweek'] = date('W', $eventstart);
    
    return $tokens;
  }
}

Just my quick little fix. The dates in the URLs are now being generated correctly.

Equ’s picture

Unfortunately, it doesn't work for me... Still have the same problem (01.01.1970) :(

greenskunk’s picture

Setting up another site on another host and I still have this issue.
When applying the fix from above ( http://drupal.org/node/256197#comment-953062 ) it works.

greenskunk’s picture

Every time I update this module I have to add in the fix (Comment #19). Is there any information I can provide to help create a permanent fix?

greggles’s picture

Status: Postponed (maintainer needs more info) » Active

@GreenSkunk - if you could provide it as a patch then it would be more likely to get fixed inside the module itself.

the1who’s picture

@GreenSkunk, I have modified in the module what you have provided in #19 and have fixed the issue on my server as well. Thank you for providing that information, that has been so helpful. Greggles referred me to this node, thanks as well greggles!

Matthew

edit: I have updated the event module prior to modifying the code using, Event 6.x-2.x-dev 2008-Nov-07 just to let you know what version I was using.

claudiu.cristea’s picture

Status: Active » Needs review
StatusFileSize
new673 bytes

Here is a patch to fix the tokens issue.

killes@www.drop.org’s picture

Status: Needs review » Fixed

thanks, applied.

Status: Fixed » Closed (fixed)

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