Imported event not showing in next event

Home Forums Calendar Products Event Aggregator Imported event not showing in next event

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1009159
    Antoine
    Participant

    Hi,

    When importing events via ICS, they do not show up on the NEXT EVENT shortcut from ENFOLD theme.

    I will also open a ticket in ENFOLD support, but maybe you already have a clue on what happen. Status of event are PUBLISHED (already checked)

    SCREENSHOT : http://i.imgsafe.org/f511a1d.png

    Thanks

    #1009431
    Brian
    Member

    Hi,

    Thanks for using our plugins. I can try to help out, but I am limited in support 3rd party coding.

    I do not know how the Next Event Shortcut Works, is it widget on the front end?

    How does an event normally get put in there?

    Let me know and I can try to help out.

    Thanks

    #1009595
    Antoine
    Participant

    Hi,

    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

    #1009668
    Brian
    Member

    Hi,

    We add a custom field for the iCal Importer:*

    _EventIcalSource

    That is the only difference. So not sure how there widget works and why it does not pick up the event.

    Let me know what you find out.

    Thanks

    *revised this message after looking at the coding.

    #1009950
    Antoine
    Participant

    Hi 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,

    #1010007
    Brian
    Member

    Ok sounds good. I will leave the ticket open.

    Our system does close tickets after two weeks of inactivity.

    If that would happen then please just create a new ticket and reference this one.

    Thanks

    #1012379
    Antoine
    Participant

    Hi 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

    #1012473
    Brian
    Member

    Hi,

    What about using tribe_get_events instead of this to get the events:

    TribeEventsQuery::getEvents

    This might work to get the next event even if it is in the middle of a multiday event:

    $events = tribe_get_events( array(
    'eventDisplay' => 'list',
    'posts_per_page' => 1
    ) );

    Does that work?

    #1012585
    Antoine
    Participant

    Hi 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!

    #1012647
    Brian
    Member

    Hi,

    So I tested this function on a multiday event:

    $upcoming = tribe_get_events( array(‘eventDisplay’ => ‘list’, ‘posts_per_page’ => 1) );

    It started on the 5th and runs to October 10th.

    It is correctly picking it up as the current event.

    So it appears their shortcode is not displaying it (sorry if that was the issue all along)

    This coding looks like it could be causing it as it checks if the Event Start Date is before today and if so it removes the event:

    $today = date("Y-m-d H:i:s");
    if ($events_date < $today) {
    unset($next->posts[0]);
    }

    That is about all I can troubleshoot on this coding though.

    You could play around with that section of coding, but since this is setup to be a timer it might be better to create your own coding to do this.

    #1012749
    Antoine
    Participant

    Hi 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!

    #1012855
    Brian
    Member

    Awesome! I am glad to see you were able to figure it out.

    I am going to go ahead and close this ticket. If you have a similar issue or another in the future, please do not hesitate to create a new ticket.

    Thanks!

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Imported event not showing in next event’ is closed to new replies.