Forum Replies Created
-
AuthorPosts
-
Antoine
ParticipantHi Brian,
Thank so much for your testing and confirming the output function is working.
I managed to fixed the issue by doing this (in case someone else got the issue with ENFOLD theme):
function fetch_upcoming() { $query = array('paged'=> false, 'posts_per_page' => -1, 'eventDisplay' => 'list'); $upcoming = TribeEventsQuery::getEvents( $query, true); return $upcoming; }And then:
function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "") { $time = time(); $next = $this->fetch_upcoming(); $upcomings = array(); foreach($next->posts as $post) { $end = explode(" ", $post->EventEndDate ); $start = explode(" ", $post->EventStartDate ); if($time < strtotime($end[0]) && strtotime($start[0]) > $time) { $upcomings[] = $post; } } if(empty( $upcomings[1] ) || empty( $upcomings[1]->EventStartDate )) return; $events_date = explode(" ", $upcomings[1]->EventStartDate ); if(isset($events_date[0])) { $atts['date'] = date("m/d/Y", strtotime($events_date[0])); } if(isset($events_date[1])) { $events_date = explode(":", $events_date[1] ); $atts['hour'] = $events_date[0]; $atts['minute'] = $events_date[1]; } $atts['link'] = get_permalink( $upcomings[1]->ID ); $title = get_the_title( $upcomings[1]->ID ); if(!empty( $atts['title'] )) { $atts['title'] = array( $atts['title'] => __("Upcoming",'avia_framework') .": " . $title ); } $timer = new avia_sc_countdown( $this->builder ); $output = $timer->shortcode_handler( $atts , $content, $shortcodename, $meta); return $output; }So just changed “posts_per_page” to be -1 (to get the full list) in the first function, then added a check date in the second one:
foreach($next->posts as $post) { $end = explode(" ", $post->EventEndDate ); $start = explode(" ", $post->EventStartDate ); if($time < strtotime($end[0]) && strtotime($start[0]) > $time) { $upcomings[] = $post; } }Thank you very much again for your support!
Antoine
ParticipantHi Brian,
I think we are close yes, I looked at this function and seems pretty handy (https://theeventscalendar.com/knowledgebase/using-tribe_get_events/)
But when I use:
$events = tribe_get_events( array( 'eventDisplay' => 'list', 'posts_per_page' => 1 ) );I don’t get any result. Previously it used “TribeEventsQuery” but when I put it in I got “Call to undefined method TribeEventsQuery::tribe_get_events() ” which is quite normal.
function fetch_upcoming() { $upcoming = tribe_get_events( array('eventDisplay' => 'list', 'posts_per_page' => 1) ); return $upcoming; } function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "") { $next = $this->fetch_upcoming(); if(empty( $next->posts[0] ) || empty( $next->posts[0]->EventStartDate)) return; $events_date = explode(" ", $next->posts[0]->EventStartDate ); $today = date("Y-m-d H:i:s"); if ($events_date < $today) { unset($next->posts[0]); } if(isset($events_date[0])) { $atts['date'] = date("m/d/Y", strtotime($events_date[0])); } if(isset($events_date[1])) { $events_date = explode(":", $events_date[1] ); $atts['hour'] = $events_date[0]; $atts['minute'] = $events_date[1]; } $atts['link'] = get_permalink( $next->posts[0]->ID ); $title = get_the_title( $next->posts[0]->ID ); if(!empty( $atts['title'] )) { $atts['title'] = array( $atts['title'] => __("Upcoming",'avia_framework') .": " . $title ); } $timer = new avia_sc_countdown( $this->builder ); $output = $timer->shortcode_handler( $atts , $content, $shortcodename, $meta); return $output; }Where am I missing something?
Thanks, feeling getting close to the solution!
Antoine
ParticipantHi Brian,
I found the issue, this is because the Event is for a period not a single day.
So what happen is that for example, let’s say we have Event from 1 to 15 and today it’s 10, the shortcode will not display the event because the starting date is in the past, but will not display the next event because the end date of the actual event is in the future.
I looked at the code and it’s using this:
function fetch_upcoming() { $query = array('paged'=> false, 'posts_per_page' => 1, 'eventDisplay' => 'list'); $upcoming = TribeEventsQuery::getEvents( $query, true); return $upcoming; }I then looked at the function (seems deprecated now?) but wasn’t able to find a variable to exclude any Event with start date < at today:
public static function getEvents( $args = array(), $full = false ) { $defaults = array( 'post_type' => Tribe__Events__Main::POSTTYPE, 'orderby' => 'event_date', 'order' => 'ASC', 'posts_per_page' => tribe_get_option( 'postsPerPage', 10 ), 'tribe_render_context' => 'default', ); $args = wp_parse_args( $args, $defaults );I know you are limited with customization, but this function is from the Events Calendar plugin so you might have an idea for the parameters that I am looking for.
Thanks
Antoine
ParticipantHi Brian,
That’s perfect! Thank you very much.
Antoine
ParticipantThis reply is private.
Antoine
ParticipantHi Nico,
The problem came as I thought from the @ symbil in the URL (which is quite common for a calendar feed), therefore I manually changed “@” to be “%40” and everything worked fine.
Not sure if you want to add this sanitary check when an URL is entered in the plugin, but still good to know.
Thanks for your support!
Antoine
ParticipantBrian,
I was thinking, isn’t this already implemented with the “Keywords” field during importation of a feed?
Where the query is made? In the event title or/and description?
Because if for example we got:
Event title: XXX – Flight for Toykyo
Event dDescription: Flight number TK001
Keyword: Tokyo
Category: TokyoThen will it works?
If so, we only need to import the same feed with different keyword for other category.
Regards,
Antoine
ParticipantHi Brian,
Thanks, that makes sense to wait for the import and then apply a function to assign a category, I will look for that and if I got something I will share it here but it can takes few days before it’s complete.
Regards,
Antoine
ParticipantHi Nico,
Yes I did tried and I got issue when I select ICS file, the IMPORT TYPE auto changed to ONE-TIME IMPORT, please look at my screenshot on the first message of this ticket:
http://i.imgsafe.org/030a258.png
When I select iCal feed, then I got error message as the URL is incorrect(but it is otherwise i would not be able to download the file, maybe because there is an @ character in the string?
Regards,
Antoine
ParticipantHi Brian,
Thanks, I will check and do some testing by changing this value in db.
I will let you know if I find something, please keep this ticket open until EOW.
Regards,
Antoine
ParticipantHi,
Thanks, that what I suspected. But is there any snippet that we can add in the functions.php file in order to auto-assign based on keywords in the events NAME or DESCRIPTION or any other fields from the ICS feed?
Thanks
Antoine
ParticipantHi,
This is an option in the ENFOLD theme using your Calendar as third party.
No specific way to enter the event, we follow the normal process. I’m checking with ENFOLD dev as well, but from your side, maybe you can help me to find something not correct in the DB when the events are imported?
Is there any difference or flag that is/are added between manual entry and automatic entry?
Thanks
Antoine
ParticipantHi,
Thanks, well we have an online calendar (Outlook Exchange) and it is published online via an URL pointing to this ICS file.
What we would like to do is having the information the calendar in the website and Outlook synced. But it doesn’t seem to have an option to import the ICS file every 30min (like for iCal).
Hope this clarify, let me know if you need more information.
Regards,
-
AuthorPosts
