Jump to content

Create ICS file from page


combicart
 Share

Recommended Posts

Hello,

I'm currently creating an Events website. I've setup an 'events' page with a date, start time and end time. I'm using the fields to print them out on the page.

However, I would like to add the option that visitors can download an ICS file so that they can quickly add the event to their calendar. I've found https://github.com/markuspoerschke/iCal for the creation of het actual ICS files. I've created a new template file (download-ics) and used one of the examples (https://github.com/markuspoerschke/iCal/blob/master/examples/example7.php) for the template.

When i'm browsing to the url with the (download-ics) template the ICS file is being downloaded correctly. However now there are only fixed values inside the ICS file.

How can I pass the variables from the actual event into the newly created (download-ics) template file so that the actual date and times can be used?

Link to comment
Share on other sites

You need to pass the page id of the event in question (probably as a GET parameter or URL segment) when you open the ICS page, then in your ICS template retrieve the corresponding page (remember to use sanitizer or (int) casting to make sure you're really getting a valid page id) and fill in the page's field values.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...