We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26482
    • 138 Posts
    Hi,

    I have the EasyEvents snippet setup and a separate Ditto call listing all events in chronological order. I was wondering how I can generate an iCal feed that viewers can subscribe to, f.e. in Google Calendar. I thought the JSON format in Ditto would be a good start. I may be able to feed this into iCalCreator, or am I mssing the bigger picture here?

    Thanks.
      • 27708 MODX Staff
      • 2,502 Posts
      It shouldn’t be that hard to do. You need to just get an iCal template with the tags etc. I would think that RSS would actually be the way to go but I am not 100% sure since I’ve never build an iCal feed.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 26482
        • 138 Posts
        How would you go about creating an iCal template? And more importantly, why? I should be able to query the database for all relevant fields, I thought.
          • 7231
          • 4,205 Posts
          You need the template of the format, not necessarily an actual template. First off there are 2 types of icalfiles, the ones you download and the ones that create live feeds to your ical app.

          To do the second (feed) you can:
          1) create a new document
          2) set template to "blank"
          3) set the content type to text/plain
          4) set the Content Disposition to inline
          5) turn off RTE

          in the content field (with no RTE active) put the "template" for the ical feed:
          BEGIN:VCALENDAR
          VERSION:2.0
          X-WR-CALNAME: [*longtitle*]
          PRODID:-//Apple Computer\, Inc//iCal 2.0//EN
          [!Ditto? &parents=`12` &display=`all` &tpl=`ical_tpl`!]
          END:VCALENDAR


          and then create the tpl chunk for the ical format:
          BEGIN:VEVENT
          DTSTART:[+eventDate_start:date=`%Y%d%mT%H%M%SZ`+]
          DTEND:[+eventDate_end:isnot="":then=`[+eventDate_end:date=`%Y%d%mT%H%M%SZ`+]`+]
          SUMMARY:[+longtitle+]
          DTSTAMP:[+editedon:date=`%Y%d%mT%H%M%SZ`+]
          END:VEVENT
          Add more parameters as needed.

          Then use the webcal protocol when creating the link:
          webcal://domain.tld/path/to/cal/feed

          This has worked for me. I think that to turn this into the download file type of ical document you would need to simply change the Content Disposition to attachment and not use the webcal in the link, but I have never used it like this.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 26482
            • 138 Posts
            Thanks for this! I’ve tweaked the template only slightly and got a working feed to import in Google Calendar. Need to get working on the definitions, I guess, since the feed seems to be showing all day events in a funny way.
            But this template has gotten me working in the right direction.

            Thanks again.
              • 21800
              • 174 Posts
              Hi, for me the thing is not yet solved.
              It works so far as the iCal (.ics) is produced and looks as it should (in an editor). But it will not load in Windows Calendar nor in Thunderbird (not a propper file format).
              The Problem as far as I see may be the linefeeds in the DESCRIPTION part. If I delete all content exept for one line it will load. There’s no difference to be seen between an .ics that works and mine.
              btw. content type is text/plain, template blank, RTF off, Content Disposition to inline (download) .