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


    I'm running MODx Evolution and am looking for a simple way to display events from multiple Google Calendars.

    We have about a dozen Google Calendars (for events organised by different groups) and would like to display the next 4 or 5 upcoming events, with the information presented/styled to match our website design (rather than using the basic Google Calendar iframe). (Visitors to the website will be able to follow a link to a different page showing the full combined Google Calendar iframe view, this is just to display the immediately forthcoming events on our home page.)

    I have not used the Google Calendar API before, and Google's documentation (perhaps especially for PHP, it seems) is quite hard to understand and follow. It seems that there are (at least!) two ways to extract calendar data: either using Google's API or some other code written by Zend. There seems to be even further complexity as the Google API appears to require authentication, although our calendars are (intentionally) public and the data can therefore be accessed by anyone.

    I also rather suspect that I don't want to be making real-time queries to Google Calendar on each page request in any case. Obtaining data, say, twice a day and then parsing the local copy would seem to be more appropriate.

    I do have local copies of the iCalendar and XML versions of our calendars, which are currently fetched by a daily cron job (so that we have our own local backup copies).

    Can anybody advise how best I might approach this problem?

    I need to:

    1. Get the next (how many?) events from each calendar from wherever I am sourcing it (I suspect my local copy would be the better choice).

    (I'm not sure quite how much data to fetch from each calendar: fetching only the next event may not be enough, as it is possible that several calendars may have no events in the immediate future, while another may have 2 or more events today, and so I would (probably) want to list all of those immediate events, not just one per calendar.)

    2. Sort the event data into ascending order.

    3. Extract the individual fields for the 'n' events that I will display (Date, Month, Year, Start time, End time, Event title, Location, Description (perhaps), link to full calendar entry (ideally, but probably not essential - a link to our full calendar page would probably be adequate)).

    4. Output the data into the webpage, presented/styled as desired.

    Am I thinking along the right lines? Would I better trying to process the XML or iCalendar data (or attempting to fetch it directly from Google Calendar)?

    PHP's SimpleXML looks like it may perhaps be of use (but even for that, there is a learning curve for me..). Is there something similar for iCalendar data (if that's a sensible way to go)?

    Or has anybody written any code for MODx that would help with this? (I have done a quick search of the forum and have found a number of threads of varying age which I am going to look through, but this will take a while so I hope it is not too impolite to ask in case anybody else happens to have more up-to-date advice more easily to hand!)

    Many thanks for any advice..
      Please don't PM me unless it's absolutely essential: if a technical question is worth asking, it's worth asking in public, so that others can share their experience, and so that all can learn from the answers.
      • 45552
      • 1 Posts
      Quote from: david55 at Nov 05, 2013, 09:57 AM


      Can anybody advise how best I might approach this problem?
      I'm a graphic designer by background, so I can't suggest a programmer's solution. Nor am I experienced with MODx. However, I have done a little work with publishing Google Calendar data. My approach was to use Google Calendar to aggregate the event information, Feedburner to get the XML, and then style it with CSS.

      Quote from: david55 at Nov 05, 2013, 09:57 AM

      I need to:

      1. Get the next (how many?) events from each calendar from wherever I am sourcing it (I suspect my local copy would be the better choice).
      (I'm not sure quite how much data to fetch from each calendar: fetching only the next event may not be enough, as it is possible that several calendars may have no events in the immediate future, while another may have 2 or more events today, and so I would (probably) want to list all of those immediate events, not just one per calendar.)
      Create an "umbrella" calendar in your Google Calendar account and share all the calendars you want to publish from with the umbrella account.

      Quote from: david55 at Nov 05, 2013, 09:57 AM

      2. Sort the event data into ascending order.
      The umbrella calendar will do this automatically.

      Quote from: david55 at Nov 05, 2013, 09:57 AM

      3. Extract the individual fields for the 'n' events that I will display (Date, Month, Year, Start time, End time, Event title, Location, Description (perhaps), link to full calendar entry (ideally, but probably not essential - a link to our full calendar page would probably be adequate)).
      Use CSS to hide unwanted elements on the published page. Not terribly elegant but it works. You may be able to trim out the unwanted elements in Feedburner.

      Quote from: david55 at Nov 05, 2013, 09:57 AM

      4. Output the data into the webpage, presented/styled as desired.
      Generate an XML feed using Feedburner (feedburner.google.com), set up a RSS subscription chunk in your page (I don't have any suggestions there), and use CSS to style. My solution did not involve a live update event list. I was publishing the same events in print and online and published both from an XML file saved to a server.

      This should at least get you up and running.

      —Michael
        • 6705
        • 79 Posts
        Thanks for the "umbrella calendar" tip. I didn't know about that! That sounds like it would certainly make getting the events in a single listing a lot easier..
          Please don't PM me unless it's absolutely essential: if a technical question is worth asking, it's worth asking in public, so that others can share their experience, and so that all can learn from the answers.
          • 6705
          • 79 Posts
          Sorry, can I ask how I actually create an "umbrella calendar" in Google Calendar?

          I'm not seeing anything obvious in the settings, and searching for help doesn't bring up anything useful.

          I have created a new calendar, and have looked through the settings thoroughly, but I can't see any way to add other calendars into this calendar, only how to create new events, etc..?

          Thanks for any advice!
            Please don't PM me unless it's absolutely essential: if a technical question is worth asking, it's worth asking in public, so that others can share their experience, and so that all can learn from the answers.