WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Events Manager] List Recurring Events as one Event (11 posts)

  1. Acts7
    Member
    Posted 2 years ago #

    So the point of recurring events is to have them list on every day.
    But I'm trying to find a way to list the recurring events as one event with a date range span.
    I have 2 calendar page templates.
    One lists "daily events"
    The other is simply a listing of events
    On the listing of events, I'd like to list the recurring events as one event with the date range (EX: April 1 - April 30 Granny's Cake Decorating Class at Hobby Lobby")

  2. shatting
    Member
    Posted 2 years ago #

    hello!

    simply add recurring="1" as a search parameter:

    [events_list recurring="1"]#F #d - #@F #@d #_EVENTNAME at #_LOCATIONNAME[/events_list]

  3. Acts7
    Member
    Posted 2 years ago #

    Problem with that is it only lists recurring events not the rest of them.

  4. shatting
    Member
    Posted 2 years ago #

    oh i understand now. you want all events, but instead of recurrences of recurring events you just want a single entry?

    - none recurrnig event
    - none recurrnig event
    - recurrnig event
    - none recurrnig event
    ...

    im afraid but i think for this youll have to define a custom shortcode:

    function em_get_events_list_shortcode_all($atts, $format='') {
    	$atts = (array) $atts;
    	$atts['format'] = ($format != '' || empty($atts['format'])) ? $format : $atts['format'];
    	$atts['format'] = html_entity_decode($atts['format']); //shorcode doesn't accept html
    	$atts['page'] = ( !empty($atts['page']) && is_numeric($atts['page']) )? $atts['page'] : 1;
    	$atts['page'] = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : $atts['page'];        
    
            // get recurrence events
            $atts['recurring']=1;
            $evts_recurring=EM_Events::get($atts);
    
            // get non-recurrence events
            $atts['recurring']=0;
            $evts=EM_Events::get($atts);
            // filter out the events that are instances of recurring events
            $non_recurrence_evts = array_filter($evts,'is_no_recurrence');
    
            // merge recurrence and non-recurring events
            $evts_all= array_merge($non_recurrence_evts,$evts_recurring);
            // sort them by start==start date+time
            usort($evts_all,'evt_start_sort');
    
            //
    	return EM_Events::output( $evts_all, $atts );
    }
    add_shortcode ( 'events_list_all', 'em_get_events_list_shortcode_all' );
    
    function is_no_recurrence($evt) {
        return $evt->recurrence_id == null;
    }
    
    function evt_start_sort($evt1, $evt2) {
        return $evt1->start > $evt2->start;
    }

    and for the display a custom conditional placeholder

    function filter_condition($show_condition, $condition, $conditionals_key, $thiss) {
    
        if ($condition == "is_recurring") {
            $show_condition=$thiss->recurrence == 1;
        }
        return $show_condition;
    }
    add_filter('em_event_output_show_condition', 'filter_condition',10,4);

    so then you can use the shortcode like this:

    [events_list_all recurring="1"]#F #d {is_recurring}- #@F #@d{/is_recurring} #_EVENTNAME at #_LOCATIONNAME<br>[/events_list_all]

    alternatively, you could just use the {is_long} conditional placeholder like this:

    [events_list_all recurring="1"]#F #d {is_long}- #@F #@d{/is_long} #_EVENTNAME at #_LOCATIONNAME<br>[/events_list_all]

    cheers, stephan

  5. Acts7
    Member
    Posted 2 years ago #

    Pastebin - to your code - just in case
    http://pastebin.com/pdtY51x6

    Thank You ! I will give this a try and post back.
    Logically - - it looks correct except one part I'm not following:

    $non_recurrence_evts = array_filter($evts,'is_no_recurrence');

    and

    usort($evts_all,'evt_start_sort');

    How does the code know to look for this as a function ... being that its in quotes?

  6. shatting
    Member
    Posted 2 years ago #

    this is how function references are done in php i guess. this kind of syntax is all over the codex (add_filter, add_shortcode,..) so i just used it.

    found some info on those callbacks here and here

  7. MichelleLeslie
    Member
    Posted 2 years ago #

    Hi Shatting, thanks for the code. Works great!

  8. MichelleLeslie
    Member
    Posted 2 years ago #

    Does anyone know how to customise Shatting's code to filter events like this by location?

    I'd like to show all the events for a location with the recurring events only showing once.

  9. Acts7
    Member
    Posted 2 years ago #

    @MichelleLeslie

    This shortcode is simply filtering the em_events.
    So you should have access to all the other arguments

    [events_list_all recurring="1" location="12"]#F #d {is_long}- #@F #@d{/is_long} #_EVENTNAME at #_LOCATIONNAME<br>[/events_list_all]

    Where "12" is the id of the location you wish to use.

  10. MichelleLeslie
    Member
    Posted 2 years ago #

    @Acts7

    Thank you for the speedy response. Much appreciated. :)

  11. wdixon
    Member
    Posted 1 year ago #

    Hi thanks for this shortcode. This list it returns shows events with starting dates in the future but emits those with ending dates in the future but starting dates in the past. Is there a way to get it to include events that are currently ongoing? Thank you in advance.

Topic Closed

This topic has been closed to new replies.

About this Topic