Hi, I’m trying to provide an iCalendar file for download which content is generated with Twig.
So I crated a new template “icalendar.html.twig” which actually contains just one line saying
{{ page.content }}
and created a new page “/calendar/icalendar.md” of that template with content
title: calendar
process:
twig: true
markdown: false
cache_enable: false
visible: false
template: icalendar
content:
items:
’@taxonomy’:
type: event
order:
by: date
dir: asc
limit: '20’
pagination: false
{% set events = page.collection({'items':{'@taxonomy.type':'event'}}).order('date', 'asc') %}
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//SabreDAV//SabreDAV//EN
CALSCALE:GREGORIAN
... and so on.
Now, what I get returned looks like an iCalendar file.
However, it cannot be parsed by some calendar software like Thunderbird/Lightning and I think that’s due to two reasons:
#1 If I enter /calendar/calendar.ics into the browser address bar, the file opens in the tab rather than providing me to download it.
#2 The content-type is text/html instead of text/calendar
To fix the 2nd problem I copied the /system/config media.yaml to /user/config/media.yaml and added
ics:
type: file
mime: text/calendar
But this seems to be totaly ignored as the content-type is still text/tml.
So my questions are:
- Did I made a completey worng turn somewhere here?
- Or how do I change the content-type and how do I achieve to provide the file as a download instead opening it in the browser tab?
Best regards,
Phil