Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2017-11-08 13:56:41

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: Outputting a valid .ics file from an Event for download

I have recherching for the [UID] and fount an explain here: https://blog.emeidi.com/2016/06/29/einen-outlook-2010-kompatiblen-icalendar-ics-generieren/

here code snippet is:

BEGIN:VEVENT
UID:5772a5d6498eef051c12ed37@domain.tld
DTSTART;TZID=Mad:20160628T182910
DTEND;TZID=Mad:20160628T183410
DTSTAMP:20160629T190304Z
SUMMARY:Bahnhof Bern
LOCATION:Bahnhof Bern
COMMENT:
END:VEVENT

So I have in my form icsitem

BEGIN:VEVENT
UID:<txp:posted format="w3cdtf" />@<txp:site_url />

now works with UID.

But now the validator means:
Your calendar parsed, but with errors.
Error: Error was: Property [DTSTAMP] must be specified once
Cause: Sorry, I couldn’t get an exact cause.

The DTSTAMP I do now inside:

BEGIN:VEVENT
UID:<txp:posted format="w3cdtf" />@<txp:site_url />
DTSTART:<txp:custom_field name="DTSTART" />
DTEND:<txp:custom_field name="DTEND" />
DTSTAMP:<txp:posted format="%Y%m%dT%H%M%SZ" />
SUMMARY:<txp:title />
END:VEVENT

now my ics-file is for iCalendar validate! :-)

But as I get the .ics-file for my iCalendar say my Calendar still: is emtpy…. arghhhh

Offline

#17 2017-11-08 14:03:04

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,202
Website GitHub

Re: Outputting a valid .ics file from an Event for download

lythande wrote #307695:

I understand now, that my timestamp was not correct. I corrected them to “20180217T150000” and End-Date same too.
(would there possible parsing the date “20180217 15:00” to “YYYYMMDDTHHMMSS”, so that I can fill in the custom-field a readable timestamp?)

Sorry for replying in bits and bots. Look at this date rewriting example in smd_wrap, which is probably helpful anyway here. Borrowing from that, I think you could do this:

<txp:smd_wrap delim="@"
     transform="date|%Y%m%dT%H%M%S">
<txp:custom_field name="DTSTART" />
</txp:smd_wrap>

TXP Builders – finely-crafted code, design and txp

Offline

#18 2017-11-08 14:04:37

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: Outputting a valid .ics file from an Event for download

sorry, i was recherching and validating, so I havent read your postings… sorry!

Now I make my rah_eo_generate-ics better how jacob say it.

But the validator has not like the DTSTAMP:<txp:posted format="iso8601"/>, so I have made it with DTSTAMP:<txp:posted format="%Y%m%dT%H%M%SZ" />.

Offline

#19 2017-11-08 14:08:00

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,202
Website GitHub

Re: Outputting a valid .ics file from an Event for download

lythande wrote #307699:

now my ics-file is for iCalendar validate! :-)

But as I get the .ics-file for my iCalendar say my Calendar still: is emtpy…. arghhhh

You’re getting there :-)

An ics file is just a text file, so can you open it in a text editor. You may be able to identify what’s missing or if there are extra lines up front or behind. Also, if you have all your events in one calendar file, you might want to try how they work individually first.

You should be able to edit the ics file directly, save it, then import it into/drop it onto your calendar.

lythande wrote #307702:

But the validator has not like the DTSTAMP:<txp:posted format="iso8601"/>, so I have made it with DTSTAMP:<txp:posted format="%Y%m%dT%H%M%SZ" />.

Yes, that works. The validator I linked to above didn’t require the Z at the end, but you may need it to get the right timezone later…


TXP Builders – finely-crafted code, design and txp

Offline

#20 2017-11-08 14:15:30

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: Outputting a valid .ics file from an Event for download

thanks, i think too, we solving it soon ;-)

jakob wrote #307697:

Inside your rah_eo_generate-ics form (misc/diverse type should be fine), you need to have this (code)

Hm, your code-snippet doesnt validate for iCalendar-validator.
he say:

Sorry, your calendar could not be parsed.
Error: Error was: Error at line 4:Expected [BEGIN], read [ ]
Cause: Sorry, I couldn’t get an exact cause.

So i think, he dont like the php-lines between ; Content-Disposition: and BEGIN:?

Offline

#21 2017-11-08 14:18:23

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: Outputting a valid .ics file from an Event for download

the iso8601 output YYYY-MM-DDTHH:MM:SS, but the validator need the timestamp without – and :, so I make the strftime inside.

Offline

#22 2017-11-08 14:19:41

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,202
Website GitHub

Re: Outputting a valid .ics file from an Event for download

What does the .ics file itself contain? Maybe there are some blank lines at the beginning.

If you’ve installed smd_wrap, you can put

<txp:smd_wrap_all>
…
</txp:smd_wrap_all>

around everything (below the ; … lines) and it should trim any preceding and trailing blank lines.


TXP Builders – finely-crafted code, design and txp

Offline

#23 2017-11-08 14:32:45

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,202
Website GitHub

Re: Outputting a valid .ics file from an Event for download

For the correct timezone, I believe you need to add after the initial opening calendar block:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Computer, Inc//iCal 1.5//EN
X-WR-TIMEZONE:Europe/Berlin

this VTIMEZONE block:

BEGIN:VTIMEZONE
TZID:Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE

And then in your actual event infos, you need to add ;TZID=Europe/Berlin to DTSTAMP, DTSTART, and DTEND, so you have something like this:

BEGIN:VEVENT
UID:20171088T232500-123@karinmuellerschmied.de
DTSTAMP;TZID=Europe/Berlin:20171088T232500
DTSTART;TZID=Europe/Berlin:20171108T122500
DTEND;TZID=Europe/Berlin:20171108T142500
SUMMARY:Text Description
END:VEVENT

and then the closing calendar entry:

END:VCALENDAR

Hope that helps…


TXP Builders – finely-crafted code, design and txp

Offline

#24 2017-11-08 14:32:56

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: Outputting a valid .ics file from an Event for download

the .ics file contains:


BEGIN:VCALENDAR
VERSION:2.0
X-WR-CALNAME:Führungstermine
PRODID:-//Apple Computer, Inc//iCal 1.5//EN
X-WR-TIMEZONE:Europe/London
BEGIN:VEVENT
UID:2017-11-07T23:29:11Z@http://mydomain.de/
DTSTART:20180217T150000
DTEND:20180217T163000
DTSTAMP:20171108T002911Z
SUMMARY:Sa, 17.02.2018
END:VEVENT
END:VCALENDAR

I have make my (validated) code inside again, because the form rah_eo_generate-ics need to have inside the BEGIN:VCALENDAR the <txp:article_custom ... />-snipped to get the custom-fields inside the article-form icsitem.

At moment I dont have parsing the readable custom-field with smd_wrap, because I think its important first to solve the ics-file itself. :-)

Offline

#25 2017-11-08 14:34:27

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: Outputting a valid .ics file from an Event for download

yes, the needed VTIMEBLOCK i do inside the rah_eo_generate-ics now.

Offline

#26 2017-11-08 14:37:10

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: Outputting a valid .ics file from an Event for download

now the .ics file is validated:

BEGIN:VCALENDAR
VERSION:2.0
X-WR-CALNAME:Führungstermine
PRODID:-//Apple Computer, Inc//iCal 1.5//EN
X-WR-TIMEZONE:Europe/Berlin
BEGIN:VTIMEZONE
TZID:Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:2017-11-07T23:29:11Z@http://mydomain.de/
DTSTART:20180217T150000
DTEND:20180217T163000
DTSTAMP:20171108T002911Z
SUMMARY:Sa, 17.02.2018
END:VEVENT
END:VCALENDAR

But still empty in my calendar….

Last edited by lythande (2017-11-08 14:37:24)

Offline

#27 2017-11-08 14:45:39

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,202
Website GitHub

Re: Outputting a valid .ics file from an Event for download

It’s working for me:

I tried it on your test domain (which you’ve now edited out) and clicking on “download ics file” creates an invite.ics and immediately the mac calendar pops up and asks which calendar I want to add it to. I chose “private” and it appeared correctly at the right place in my calendar.

I also tried creating ics files from your code blocks above with a text editor and then double-clicking on them to open them in the mac calendar and that worked too (also with blank lines in front).


TXP Builders – finely-crafted code, design and txp

Offline

#28 2017-11-08 14:51:37

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: Outputting a valid .ics file from an Event for download

hmmm, why doesnt work on my mac? :-(
I have Mountain Lion 10.8.5 and not problems to get another .ics-files in my calendar.

Offline

#29 2017-11-08 14:58:54

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,202
Website GitHub

Re: Outputting a valid .ics file from an Event for download

Hmm, I’m on the most recent macOS. Can you compare your generated ics-file against an ics file that works? Maybe you can identify relevant differences…

See also this thread which suggests that if you add METHOD:PUBLISH underneath the PRODID line, you may also get the request to choose your calendar in Mountain Lion.


TXP Builders – finely-crafted code, design and txp

Offline

#30 2017-11-08 15:36:21

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: Outputting a valid .ics file from an Event for download

Okay, I have a ics-file, that works and compare it with my ics-file. So I see some differences and have solved it.
But its still doesnt work on my mac…

Here my new .ics-file:


BEGIN:VCALENDAR
VERSION:2.0
X-LOTUS-CHARSET:UTF-8
X-WR-CALNAME:Führungstermine
PRODID:http://my-domain.de
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:2017-11-07T23:29:11Z@http://mydomain.de/
CLASS:PUBLISH
ORGANIZER:
SUMMARY:Sa, 17.02.2018
DTSTART;TZID=Europe/Berlin:20180217T150000
DTEND;TZID=Europe/Berlin:20180217T163000
DTSTAMP:20171108T002911Z
LOCATION:Bundeskunsthalle Bonn
COMMENT:
DESCRIPTION:(Beschreibungstext des Artikels)
END:VEVENT
END:VCALENDAR

and here a .ics-file from the german train:

BEGIN:VCALENDAR
VERSION:2.0
X-LOTUS-CHARSET:UTF-8
PRODID:http://www.hacon.de
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:20171111082300@hafas
CLASS:PUBLIC
SUMMARY:Kassel Hbf -> Marburg(Lahn)
DTSTART;TZID=Europe/Berlin:20171111T082300
DTEND;TZID=Europe/Berlin:20171111T093300
DTSTAMP:20171108T162100Z
DESCRIPTION:Reise: Kassel Hbf nach Marburg(Lahn)\nDatum: 11.11.17\n-\nab 08:23 Kassel Hbf - Gleis 7 (RE  4155)\nan 09:33 Marburg(Lahn) - Gleis 4\n-\nDauer: 1:10 \n\nAlle Angaben ohne Gewähr. Fahrplanänderungen vorbehalten. Bitte prüfen Sie kurz vor der Reise den aktuellen Fahrplan unter: www.bahn.de\n 
END:VEVENT
END:VCALENDAR

Last edited by lythande (2017-11-08 15:36:51)

Offline

Board footer

Powered by FluxBB