We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    This is an auto-generated topic for <a href="http://modxcms.com/extras/package/575">iCalendar 0.0.1-beta</a> by rolf.

    Brief Description:
    iCalendar snippet, by rolf ahlborn

    This snippet will collect ressources/documents from defined folder(s) and creates an ics-file for downloading or subscribing your dates/events into iCal or Outlook or others.
      • 13094
      • 58 Posts
      I figured out, that SnowLeo’s iCal doesn’t works with the global time zone parameter.

      If your cal-tool shows unespected dates, a quick fix will be to add the time zone id in every event and strip the last "Z" at the end of the date/time-value like this:

      ...
      $output .= "DTSTART;TZID=Europe/Berlin:" . date("Ymd", $evtdate) . "T" . date("His", $evtdate) . "\n";
      ...
      $output .= "DTEND;TZID=Europe/Berlin:" . date("Ymd", $timeOffset) . "T" . date("His", $timeOffset) . "\n";
      ...


      I’ll fix this in next version.

      If this is a proprietary behavoir of iCal, I’ll have to build a switch to export a correct iCalender text into the ics-file undecided

      Cheers,
      rolf
        • 11858
        • 130 Posts
        Hi iRolf,

        I love the iCalendar snippet - works great!

        I have one problem though, the calendar relies on the pub_date and unpub_date of the document. Is there any way to respecify this to TVs? So I can have a calendar generated from documents that are already published on the site and use date type TVs to specify the start and end dates?

        I don’t know much PHP and while I feel I have a grasp of your code, I tried using a date type TV called "general_date" and changing the line:

          $childArr = $modx->getAllChildren($parent ,$sortBy, $sortDirection ,'pub_date,unpub_date,id,pagetitle,parent,deleted');
        


        to

          $childArr = $modx->getAllChildren($parent ,$sortBy, $sortDirection ,'pub_date,unpub_date,id,pagetitle,general_date,parent,deleted');
        


        and it threw up an error obviously to my basic understanding.

        Any idea how I could specify start and finish dates with tv’s?
          • 13094
          • 58 Posts
          hi Hat-rack,

          thank you for your positive comment.

          To get the TVs work for you, I think you’ll have to do somethin like this:
           foreach($children as $child){
          ...
              $subTV = $modx->getTemplateVarOutput(array("smallImg","bigImg","year"),  $child['id'], $published = 1);
          ...
          

          which delivers you in this case the values of three TVs, called ’smallImg’, ’bigImg’ and ’year’ of a published (value 1) child document. (I picked this from another snippet)
          You can access the values like a normal associative array:
          $smallImg = $subTV["smallImg"]; //and so on...

          Hope this helps.

          Kind regards,
          rolf