Help Desk

Getting an event from our calendar to another organization's calendar fully inta

  • Posts: 44 Topics: 36
    | Permalink

    We need to be able to **easily** — as in have a button or a link with “Save to My Calendar” on it — that works and keeps the data intact. The Google save button doesn’t keep everything intact and it is just for Google calendars. The save iCal data works, but it doesn’t really save to a user’s calendar; It creates a duplicate calendar on the user’s screen that doesn’t behave like the user’s own root calendar. Most importantly to us. that duplicate calendar doesn’t embed properly into an organization’s website.

    Let me explain the embedding problem, just in case I need to. Organizations will embed their Google or other calendar using some html shortcode. When the iCal save button creates a duplicate calendar, instead of saving to the user’s root calendar, the duplicate calendar is not included in the html shortcode and the event does not appear on their website — even though it may appear on their Google calendar.

    Two prongs:
    1. Is there anyway to improve retention of things like Google’s recurring data and venue data and such?
    2. Is there anyway to get iCal data to not create a duplicate calendar but to save right on to the user’s calendar?

    Thank you very much in advance for any suggestions you may have.

    Posts: 10727
    | Permalink

    Hi. Thanks for your detailed request.

    The first sounds like a “data in from Google” question, while the second sounds like a “data out to Google” question.

    1)

    Event Aggregator does not import recurrence schedules.

    What venue data are you referring to and how are you expecting it to work?

    2)

    The way iCalendar clients (e.g. Apple Calendar, Google Calendar, Outlook) work is that — if there’s more than one event — it’ll ask if you want to add this new calendar. The only way to add multiple events to an existing Google Calendar at once is to do so manually (https://www.howtogeek.com/howto/30834/add-an-ical-or-.ics-calendar-to-google-calendar/ has a step-by-step how-to)

    If, instead, there’s a single event, it’ll ask you which of your existing calendars you want to import it to.

    You can get single .ics files from each event’s single event page view.

    With this information, please let me know if you have any follow-up questions.

    Posts: 44 Topics: 36
    | Permalink

    Hi Cliff,
    I am pretty sure (I apologize if I am wrong) you missed the second part of my question. First please allow me to reexplain. In last paragraph I will make a follow up request. Both parts of my original questions are OUTPUT questions, not input questions and pertain to how others use our Events Calendar and the features we offer them. Our users (other organizations) are trying to use the two buttons on the top of an event on our calendar to transfer an event from our calendar to their calendar and ultimately *to their website*. The “+iCal Button” saves to a duplicate calendar on whatever calendar they last used (be it outlook, google, whatever), but does not save to their root calendar. The fact that the ultimate goal is to transfer the event to their website is crucial. The groups use calendars such as Google or Timely and then html code to embed their **root** calendar into their website. Therefore, the duplicate calendars that the +iCal button creates do not get included in the html embed code unless their html code of their website is modifed (something we don’t want to make them do just to add an event to their calendar). Please try it.

    Regarding the +Google button, this does in fact save to their root calendar and so, yes, does get posted to their calendar. However, the data is not left complete. For example, if a venue is named “Capitol Theater” in the Event Calendar the name does not get through to the Google calendar, only the address. Most people will want to know the name of the place they are looking for. That is just one example of the event details that do not survive a Google save intact. Our users have already complained about the quality of the data.

    Follow up Request: I think the iCal data may retain more data intact than the Google save, so I am focusing on it.
    I think the answer is you currently do not have a feature that meets our needs. But given that, do you have any references on how we might attack the problem writing our own customizations or scripts that would save iCal data to a user’s ROOT calendar or allow the user to specify a destination in the save process? Or might you be interested in making such an upgrade? I think to allow the user to specify a destination for saving the iCal data might not be a difficult upgrade and would be very useful.

    Thank you very much in advance for your help.

    Posts: 10727
    | Permalink

    .ics files (whether downloaded or via a URL) are handled according to your operating system or application settings. Different applications have different options and preferences settings.

    If moving events from Site A to Site B — and both sites use The Events Calendar — the site(s) receiving the events from Site A would be able to use Event Aggregator to do so with as much data integrity as possible from our plugin suite.

    If those consuming your calendar do not also use The Events Calendar, they could use the iCal export URL to do similar functionality (e.g. if Timely can absorb an iCal URL on a regular-import basis). You can force the iCal URL to output more than the next 30 upcoming events via a snippet like this:

    To have events from an iCal URL import to a GCal’s root calendar, you have to download it to your hard drive and then import it into a specific calendar, as documented here: http://www.mccambridge.org/blog/2008/03/howto-merge-google-calendars-together/

    Again, this is the way each iCalendar client (GCal being one of them) operates.

    ===

    Regarding venue titles coming through iCal files:

    Our iCal export’s LOCATION is currently just the full address.

    To also add the venue title — which may or may not be well-received by the calendar application — you should be able to accomplish this by leveraging the tribe_ical_feed_item filter. Let me know if you need help doing so.

    Also let me know if you have any remaining questions.

    Posts: 44 Topics: 36
    | Permalink

    Hi there,

    I hope this is not too bothersome a question to pop up over the holidays! I saw your post and understand if the response time is slower than usual. However, we are hoping for an answer soon, as we are getting antsy about these problems on the site. Carolyn, who posted the earlier questions, asked me to get involved. I’m a volunteer developer, with some PHP experience from long ago, but can hopefully figure it out.

    Your previous answers have been helpful, and the code examples that I found for tribe_ical_feed_item filter look promising. I’m glad the ical export is so customizable! I hope we can custom the output of the .ical export to include the missing data elements of venue name for the Location field, and also populate the missing Organizer field (we’re not seeing it in the .ical text file).

    The number of different examples I can find just by Googling tribe_ical_feed_item are a bit overwhelming. Would you be able to help with a code snippet showing how to just override the behavior of that specific Location field? Or, help me find the best docs on how to use this? I have had a bit of trouble finding the docs on that add_filter function which I see in the examples. My docs search didn’t find it.

    We also would like to have the Venue Name included. My reading of the spec suggests it belongs in the Location. I have seen it mentioned that some calendars don’t handle it well, so maybe you remove the venue for compatibility. Our users mostly rely upon Google Calendar, so I hope it works for that. We would appreciate any heads up on knowing which calendars might break upon receiving the Venue name within the Location field.

    Thanks again! — Sheila

    Posts: 10727
    | Permalink

    Hi, Sheila.

    The tribe_ical_feed_item filter is found in /wp-content/plugins/the-events-calendar/src/Tribe/iCal.php

    If you’re unfamiliar with WordPress but know PHP, search that file for “do_action” and “apply_filters” to see what is easily customizable.

    For your specific request, the location should be coming through (see Line 327 of that file). Additionally, Organizer should appear per Line 371 of that file.

    Please let me know how this goes for you.

    Posts: 44 Topics: 36
    | Permalink

    Thanks very much for the response, Cliff. After perusing the source code you mentioned, here is what I did to prepend the venue name to the location. Could you review this to let me know if this is the most appropriate way to accomplish this? It works, but I wonder if it will cause a problem to create an entire new instance of Tribe_Events_Main.

    add_filter( 'tribe_ical_feed_item', 'tribe_ical_add_venue_name', 10, 2 );
    function tribe_ical_add_venue_name ( $item, $eventPost ) {
        $venue_name = strip_tags(tribe_get_venue());
        $tec = Tribe__Events__Main::instance();
        $location = $tec->fullAddressString( $event_post->ID );
        $str_location = str_replace( array( ',', "\n" ), array( '\,', '\n' ), html_entity_decode( $location, ENT_QUOTES ) );
        $item[] = 'LOCATION:' . $venue_name . '\' . $str_location;
        return $item;
    }

    With this enabled, the venue name shows up in front of the address when I manually import the .ical into the Google calendar. The map link from the Google calendar seems to also work ok. The venue name does look a little funny with the ‘\’ visible after the venue name.

    Also, is there any hook for applying this same logic to the +Google button?

    Thanks again, and Happy New Year!!!

    Posts: 10727
    | Permalink

    Hi. All that looks good except I’d recommend using PHP_EOL instead of “\n”

    For the “+ Google Calendar” button, please see the tribe_google_calendar_parameters filter in /wp-content/plugins/the-events-calendar/src/Tribe/Main.php

    Posts: 44 Topics: 36
    | Permalink

    Thanks! I will try something similar with tribe_google_calendar_parameters.

    Incidentally, could you help me understand what the hard-coded 10,2 parameters refer to? I copied these from other add_filter examples, but could not find the reference documentation for the add_filter function.

    Posts: 10727
    | Permalink

    Sure!

    Basically the 10 is always the default priority and the 2 is normally 1 by default.

    In other words, add_filter( ‘this_thing’, ‘my_thing’) is exactly the same as add_filter( ‘this_thing’, ‘my_thing’, 10, 1)

    You always need to look for apply_filters for ‘this_thing’ in the code to know what parameters are sent by the filter — i.e. what data is filterable.

    Example A: apply_filters( ‘this_thing’, $url );

    If you did add_filter( ‘this_thing’, ‘my_thing’, 10, 2), that’d be incorrect because only 1 parameter is sent along with this specific filter.

    Example B: apply_filters( ‘this_thing’, $url, $event, ‘bob’, $version );

    There are 4 parameters sent with this filter.

    Only the first — $url — is returnable/modifiable. However, the other 3 are there in case you need to run some logic against them in order to know how to modify $url.

    If you did add_filter( ‘this_thing’, ‘my_thing’, 10, 2) — because you don’t need ‘bob’ or $version — then you could modify $url based on $event.

    If you need $version to know how to modify $url, then you’d need to do add_filter( ‘this_thing’, ‘my_thing’, 10, 4). You can’t skip the second $event and third ‘bob’ parameters if you only need the first $url and fourth $version parameters; you just wouldn’t use $event or $bob variables in your custom function:

    function my_thing( $url, $event, $name, $version) {
    if( 'beta' === $version ) {
    return 'https://www.google.com/beta/';
    } else {
    return $url; // unmodified but we always need to return something when doing a filter
    }
    }

    As far as your custom function’s parameters go, you can name them whatever you want. In this example, $name will always equal the ‘bob’ string (because that’s what’s sent via apply_filters), but you need to “use” it by giving it a variable name… $bob, $name, $blah_blah — its variable name doesn’t matter and doesn’t have to match that from apply_filters.

    For the priority… 10 is the default; 9 runs before 10, which runs before 50. The minimum is zero. The maximum is the PHP_MAX_INT constant (i.e. a super big number), but common practice is something like 100 or 999 if you really need to ensure your filter runs last (i.e. overrides other filters that ran before it, such as at priority 10).

    I hope this helps. If you need even more info about this, check out https://theeventscalendar.com/tips-working-wordpress-actions-filters/

    Posts: 44 Topics: 36
    | Permalink

    Wow, thanks! That was an extremely helpful reply! I was not aware of this WordPress-ism, and had earlier assumed filters were specific to The Events Calendar.

    Posts: 10727
    | Permalink

    You bet! Please let me know if you have any follow-up questions on this topic.

    Posts: 44 Topics: 36
    | Permalink

    Yay! It works! The +Google button now carries the export name. Here’s what we did:

    function gcal_venue_name_in_location ( array $parameters ) { 
        $venue_name = strip_tags(tribe_get_venue()); 
        $parameters['location'] = $venue_name . '@' . $parameters['location']; 
        return $parameters; 
    } 
    add_filter( 'tribe_google_calendar_parameters', 'gcal_venue_name_in_location' );
    Posts: 44 Topics: 36
    | Permalink

    Our status on this issue, to have events copy fully intact to other calendars:

    • Venue name now appears in both .ical and +Google. Thanks for the great help!

    • Organizer comes across in .ical, but the Google calendar UI seems to lack support for an organizer field. It’s odd, because the event import API does include an organizer field. When I add an organizer as a parameter, it is not visible. Our workaround will be to pre-pend the organizer to the description…unless you have better ideas!

    • When events are imported to the Google calendar via either method, the user is presented with a calendar destination, which appears to be the default or “root” calendar. So I don’t think that is an outstanding issue.

    Posts: 10727
    | Permalink
    Correct Answer

    Sorry for the delayed reply!

    I’m very glad you got things working with a little direction. Prepending to Title or appending to Description might be good ways to go if this information is vital and likely to not change.

    Please let me know if there’s anything more I can do for you at this time.

    Posts: 7
    | Permalink

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

    | Permalink

The topic ‘Getting an event from our calendar to another organization's calendar fully inta’ is closed to new replies.