WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
ical templates out-of-date (8 posts)

  1. webaware
    Member
    Posted 2 years ago #

    G'day Marcus,

    The templates for ical are now out of date since the reorg of the EM_Event object. I just fixed my ical code which was loosely based on one of those templates (I use an AJAX-style link to deliver an .ics file for event from a link on the event-single template); here's the most pertinent bit relating to start and end dates:

    $gmtOffset = 60 * 60 * get_option('gmt_offset');
    $ics[] = 'DTSTART:' . date('Ymd\THis\Z', strtotime("{$EM_Event->event_start_date} {$EM_Event->event_start_time}") - $gmtOffset);
    $ics[] = 'DTEND:' . date('Ymd\THis\Z', strtotime("{$EM_Event->event_end_date} {$EM_Event->event_end_time}") - $gmtOffset);
    $ics[] = 'DTSTAMP:' . date('Ymd\THis\Z', strtotime($EM_Event->event_modified) - $gmtOffset);

    There are other bits where field names now need event_ prefix etc, but that date/time one just bit me in the bum twice today so I thought I'd share in case anyone else needs it.

    (I should probably write up a blog post about this sometime, but in the meantime you might want to drop that into your templates when you get around to updating them)

    http://wordpress.org/extend/plugins/events-manager/

  2. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    i think those are correct actually. There might be some places missing the prefix, but there's something in place to also populate the old fields name for compatability.

    careful with ->end and ->start, because those are done on purpose, they're timestamps for that start/end date/time.

  3. webaware
    Member
    Posted 2 years ago #

    Um, that is my point; your ical templates use ->start and ->end, but they're empty, so you need to use ->event_start_date + ->event_start_time to get DTSTART, etc.

  4. webaware
    Member
    Posted 2 years ago #

    OK, I blogged my code for adding iCalendar links to event pages:

    http://snippets.webaware.com.au/snippets/give-your-events-manager-events-an-add-to-calendar-link/

  5. webaware
    Member
    Posted 2 years ago #

    And... I just "discovered" the #_EVENTICALLINK placeholder (duh!)

    And... I was mixed up. Somehow I had "fixed" my old code to have event_start and event_end, which of course don't exist. Have replaced with start and end now.

    <slinks away with tail between legs> :)

  6. webaware
    Member
    Posted 2 years ago #

    But... your iCal template is using ->modified for the timestamp, which s now empty because that data (as a string) is in ->event_modified (so either you need to put the data back into ->modified or change the template)

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    start and end are definitely created each time (in EM_Event::load_postdata()):

    $this->start = strtotime($this->event_start_date." ".$this->event_start_time);
    $this->end = strtotime($this->event_end_date." ".$this->event_end_time);

    If it's not available, then it's a bug in some way (although for me this works as expected)

    You're right about the ->modified one though, will fix.

  8. webaware
    Member
    Posted 2 years ago #

    Yeah, I don't know where my brain was, probably insufficient level of bourbon which I'm addressing right now.

    cheers,
    Ross

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic