WordPress.org

Ready to get started?Download WordPress

Forums

Event Organiser
eo display reoccurence (27 posts)

  1. susee
    Member
    Posted 1 year ago #

    hi Stephen,

    Is there a possibility to show reoccurend events only once in the [eo_events]-list?

    To show the reoccurend events only once in the format:
    event xy every monday from 18:00 to 23:00 at venue xy

    And how to exclude it in the main event-list?

    thanks for your great work!
    sincerly su

    http://wordpress.org/extend/plugins/event-organiser/

  2. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    You can 'group occurrences' to show only the next instance by using the group_events_by attribute:

    [eo_events group_events_by="series"]

    For the main event list - there should be an option in the plug-in settings. This will effect all the venue, category, and other event-archive pages.

    To show the recurrence summary is not possible with the event list shortcode. I'm afraid you'll need to create a custom shortcode which handles this - or code in a loop into your theme.

    If you do decide to do either of those, I would do it as follows: (set 'group_events_by' to 'series' in the $args array).

    $events = eo_get_the_events( $args );
        if( $events ){
             foreach( $events as $event ){
                if( eo_reoccurs( $event->ID ){
                    //Event reoccurs - use eo_get_event_schedule()
                }else{
                    //Event is one off
                }
             }
        }

    Documentation for functions can be found here. Not everything is documented (including eo_get_event_schedule - for that see the source - its fairly well documented there).

    Alternatively you can use the eo_get_schedule_summary() function (passing the event post ID - which retrieves the summary you see in the admin.

  3. susee
    Member
    Posted 1 year ago #

    thank you for your quick reply.
    I´m working on a function to check out the right formats...
    is there a possibility to ask for the endday of the next occurence?
    thx su

  4. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    See this function. It takes the event (Post) ID and returns an array index by 'start' and 'end', with the values being php DateTime objects - corresponding to the next occurrence of that event. (Or false if there isn't one).

  5. susee
    Member
    Posted 1 year ago #

    thanks that should work!

  6. susee
    Member
    Posted 1 year ago #

    yepp it worked,...

    only the order doesnt work no more:
    example(german date-format):
    04.10.12 von 19 bis 22 Uhr
    30.09. - 04.10.12
    03.10.12 von 16 bis 23 Uhr
    10.10. - 23.10.12 von 08 bis 16 Uhr
    09.10. - 12.10.12 von 09 bis 21 Uhr

    these are single and reoccurend events (I did cut off the the titles for a better overview here)

    my $args:
    'event_end_after' => 'today',
    'order' => 'ASC',
    'group_events_by' => 'series',
    'orderby' => 'event-category'
    the result is the same if I change ASC to DESC

    do you have any clue, what could be the reason?
    thx su

  7. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    You can't order by event-category unfortunately. The only orderby' values that are allowed are those supported byget_post()andeventstartandeventend`.

  8. susee
    Member
    Posted 1 year ago #

    sorry that was only a test.
    I also tested eventstart.
    with the same output

  9. susee
    Member
    Posted 1 year ago #

    <?php
    //INIT
    $event_args = array(
    /*
        //'numberposts' => 5,*/
    	'group_events_by' => 'series',
        'orderby' => 'eventstart',
        'event_end_after' => 'today',
        'order' => 'ASC'
    );
    $events = eo_get_events($event_args);
    if ($events):
        $return= '';
        global $post;
        $temp = $post;
    
        foreach ($events as $post):
    //Time-VARS
    	//	Check if is reoccurend
    	if(eo_reoccurs()){
    		//echo"ich komme wieder<br>";
    		//$dayOfWeek, $startDay, $startDayShort, $endDay, $endTime
    		//If the event is occurring again in the future, display the date
    		$dayOfWeek= eo_get_next_occurrence('l');
    		$startDay= eo_get_next_occurrence('d.m.y');
    		$startTime= eo_get_next_occurrence('H');
    		$startDayShort=eo_get_next_occurrence('d.m.');
    		$endDay=eo_format_date($post->EndDate,'d.m.y');
    		$endTime= eo_format_date($post->FinishTime,'H \U\h\r');
    
    	}else{
    		//echo"ich komme nur einmal<br>";
    		//$dayOfWeek, $startDay, $startDayShort, $endDay, $endTime
    		//single-event
    		$dayOfWeek= eo_get_schedule_start('l');
    		$startDay= eo_get_schedule_start('d.m.y');
    		$startTime= eo_get_schedule_start('H');
    		$startDayShort=eo_get_schedule_start('d.m.');
    		$endDay=eo_format_date($post->EndDate,'d.m.y');
    		$endTime= eo_format_date($post->FinishTime,'H \U\h\r');
    	}
    
    	//Check if is only one day or more days
    	if($startDay==$endDay){
    		//is only at one day
    		$givenDate=$startDay;//output Date = $startDay
    	}else{
    		//is on more than one day
    		$givenDate=$startDayShort.' - '.$endDay;//output Date = $startDayShort - $endDay
    	}
    	//Check if all day, set format accordingly
    	if( eo_is_all_day($post->ID) ){
    		//Date without time
    		$dateNTime=$givenDate;
    	}else{
    		//Date with time
    		//output dateNTime = $givenDate + Time
    		$dateNTime=$givenDate.' von '.$startTime.' bis '. $endTime;
    	}
    
    //EVENT-INFO
    	$eventTitle=$post->post_title;
    	$eventUrl=get_permalink($post->ID);
    	//$eventCat="";
    	//Check for current category-slug
    	$terms = get_the_terms( $post->ID, 'event-category' );
    	if ( $terms && ! is_wp_error( $terms ) ){
    		$su_event_cats = array();
    		foreach ( $terms as $term ) {
    			$su_event_cats[] = $term->slug;
    		}
    		$eventCat = join( ", ", $su_event_cats );
    		//echo $su_on_cat;
    	}
    
    //TEST-VARS
    	/*echo "startTime".$startTime."<br>";
    	echo "endTime".$endTime."<br>";
    	echo "startDay".$startDay."<br>";
    	echo "endDay".$endDay."<br>";
    	echo "dateNTime".$dateNTime."<br>";
    	echo "eventCat".$eventCat."<br>";
    	echo "eventTitle".$eventTitle."<br>";
    	echo "eventUrl".$eventUrl."<br><hr>";*/
    //DESIGN
    	echo '<div style="width:90%; margin:6px auto; padding:6px; border: 1px dotted #fff; ">';
    	//echo $eventCat;
    	echo '<h3><a title="'.$eventTitle.'" href="'.$eventUrl.'"><strong>'.$eventTitle.'</strong></a></h3>';
    	echo $dateNTime;
    	echo '</div>';
    
    	endforeach;
    	//Reset post variable
        $post = $temp;
    endif;
    ?>
  10. susee
    Member
    Posted 1 year ago #

    so now the full script.
    maybe there some errors?

  11. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    Hi susee - this seems to be working for me...?

    What exactly is the issue, does not order by date, or is it only ordering in descending order and doesn't work for ascending? I pretty much copied and pasted your script, so if its not working - maybe it could be a plug-in conflict?

  12. susee
    Member
    Posted 1 year ago #

    it does not order by day
    nor by category.
    I don´t think it´s a plugin-conflict.
    even if all (that are only few) plugins are deactivated the problem is the same...

    here a output-list with better description:

    a long and reoccurend (1. category)
    09.10. - 12.10.12 von 09 bis 21 Uhr

    a short and reoccurend (2. category)
    03.10.12 von 16 bis 23 Uhr

    a long single event (3. category)
    10.10. - 23.10.12 von 08 bis 16 Uhr

    a short single event (1. category)
    04.10.12 von 19 bis 22 Uhr

    a long single event (3. category)
    30.09. - 04.10.12

    This one war produced with DESC...
    I dont see any order at all.

  13. susee
    Member
    Posted 1 year ago #

    p.s. thanks for your help :-)

  14. susee
    Member
    Posted 1 year ago #

    hi Stephen,
    I tested the shortcode [eo_events group_events_by="series"]
    on a nother page. The Output here is not correct as well:

    - long single event (3.category) am 30.09.12 (no end day)

    - one day single (1.category)event am 04.10.12 19:00 (no end time)

    -long single event(3.category)am 10.10.12 08:00 (no endday/time)

    - one day single reoccurend am 02.04.08 16:00 (first startday not the next and no end time)

    - long reoccurend am 11.09.12 09:00 (first startday not the next and no end time)

  15. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Susee,

    What do you mean by 'no end day'? All events should have an end date/time.

    As for the previous lists, I've noticed that in the case of recurring events you are using the event's 'schedule start' (i.e. when the event first started) rather than the current occurrence - and also eo_get_next_occurrence(). This could potentially cause distorted results.

    Try the following (this works for me using a variety of recurring and non-recurring events):

    <?php
    $event_args = array(
    	'group_events_by' => 'series',
        'orderby' => 'eventstart',
        'order' => 'desc'
    );
    
    	$events = eo_get_events($event_args);
    	if ($events):
    		global $post;
    		$temp = $post;
    		foreach ($events as $post):
    			echo eo_get_the_start('Y-m-d').'</br>';
    		endforeach;
    
    		//Reset post variable
        		$post = $temp;
    	endif;
    ?>
  16. susee
    Member
    Posted 1 year ago #

    I use the eo_get_next_occurrence only in case of reoccurence.
    Only if the event is a single event I use eo_get_schedule_start.

    The dates are correct in my script.
    But it is not nice when the dates are not ordered.
    If I only use [eo_events] without declining the series, the order is correct. But this brings the reoccurend events to take place over the complete event-list.
    The blog-users must be able to see the events in the correct order but not thousend instances of reoccuring events....
    With your last script the first occurence is shown, not the next and the order still isn´t correct.

    If a correct sorting isn´t possible, I´ve got to cut of the reoccurend events from the complete event-list. :-(

    Or do you see a possibility to sort ist with the next occurence?

  17. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    Hi susee,

    If you only want the next occurrence to be shown, then you can use 'event_start_after'=>'today', or 'event_end_after'=>'today'. Basically when you group by series the earliest occurrence satisfying the criteria is used. (Hence if you don't restrict to events starting after today then that'll include the first occurrence).

    Currently it seems you are querying all occurrences and grouping by series. So an event that recurrs every month that started last year and occurs next week is included, but its sorted by the date of the first occurrence - hence will appear at the bottom. But by using eo_get_next_occurrence() you display next week's date. Hence it looks unordered.

    Hope that makes sense: :).

  18. susee
    Member
    Posted 1 year ago #

    will test a bit further.
    but I guess you understand my wish?
    would be nice to find a solution
    not only for the reoccurencies

  19. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    I'm pretty sure my last post is what you're after. To only show the next occurrence of recurring events: group by series and only get future events:

    $event_args = array(
    	'group_events_by' => 'series',
        'orderby' => 'eventstart',
        'event_start_after'=>'today'
    );
  20. susee
    Member
    Posted 1 year ago #

    You think 'event_end_after' => 'today' work too?

  21. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    Yup - it just depends on whether you consider a running event to past, or not.

  22. susee
    Member
    Posted 1 year ago #

    sorry, for my inattentiveness.
    ok, then I´ve got to split it into to parts:
    1. single events
    2. reoccuring events
    or otherwise
    ...

  23. susee
    Member
    Posted 1 year ago #

    two parts

  24. susee
    Member
    Posted 1 year ago #

    strange your answers do reach me late

  25. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    You don't need to split the list up...

    The following will list the next occurrence for each event in date order:

    <?php
    $event_args = array(
    	'group_events_by' => 'series',
        'orderby' => 'eventstart',
        'event_start_after' => 'today'
    );
    
    	$events = eo_get_events($event_args);
    	if ($events):
    		global $post;
    		$temp = $post;
    		foreach ($events as $post):
    			echo eo_get_the_start('Y-m-d').'</br>';
    		endforeach;
    
    		//Reset post variable
        		$post = $temp;
    	endif;
    ?>
  26. susee
    Member
    Posted 1 year ago #

    nope
    the result
    2012-10-04
    2012-10-10
    2012-10-03
    2012-10-09

  27. susee
    Member
    Posted 1 year ago #

    hi Stephen,
    for me the following will work for the moment.
    But if there will be another solution in future, maybe you like to post it here.
    thx su

    <?php
    //INIT
    $event_args = array(
    	'group_events_by' => 'series',
        'orderby' => 'eventstart',
        'event_end_after'=>'today'
    );
    $events = eo_get_events($event_args);
    if ($events):
        $return= '';
        global $post;
        $temp = $post;
    	$returnSingleEvents="<div>";
    	$returnReoccuringEvents="<div>";
    
        foreach ($events as $post):
    //Time-VARS
    	//	Check if is reoccurend
    	if(eo_reoccurs()){
    		//echo"ich komme wieder<br>";
    		//$dayOfWeek, $startDay, $startDayShort, $endDay, $endTime
    		//If the event is occurring again in the future, display the date
    		$isReo=true;
    		$dayOfWeek= eo_get_next_occurrence('l');
    		$startDay= eo_get_next_occurrence('d.m.y');
    		$startTime= eo_get_next_occurrence('H');
    		$startDayShort=eo_get_next_occurrence('d.m.');
    		$endDay=eo_format_date($post->EndDate,'d.m.y');
    		$endTime= eo_format_date($post->FinishTime,'H \U\h\r');
    
    	}else{
    		//echo"ich komme nur einmal<br>";
    		//$dayOfWeek, $startDay, $startDayShort, $endDay, $endTime
    		//single-event
    		$isReo=false;
    		$dayOfWeek= eo_get_schedule_start('l');
    		$startDay= eo_get_schedule_start('d.m.y');
    		$startTime= eo_get_schedule_start('H');
    		$startDayShort=eo_get_schedule_start('d.m.');
    		$endDay=eo_format_date($post->EndDate,'d.m.y');
    		$endTime= eo_format_date($post->FinishTime,'H \U\h\r');
    	}
    
    	//Check if is only one day or more days
    	if($startDay==$endDay){
    		//is only at one day
    		$givenDate=$startDay;//output Date = $startDay
    	}else{
    		//is on more than one day
    		$givenDate=$startDayShort.' - '.$endDay;//output Date = $startDayShort - $endDay
    	}
    	//Check if all day, set format accordingly
    	if( eo_is_all_day($post->ID) ){
    		//Date without time
    		$dateNTime=$givenDate;
    	}else{
    		//Date with time
    		//output dateNTime = $givenDate + Time
    		$dateNTime=$givenDate.' von '.$startTime.' bis '. $endTime;
    	}
    
    //EVENT-INFO
    	$eventTitle=$post->post_title;
    	$eventUrl=get_permalink($post->ID);
    	//$eventCat="";
    	//Check for current category-slug
    	$terms = get_the_terms( $post->ID, 'event-category' );
    	if ( $terms && ! is_wp_error( $terms ) ){
    		$su_event_cats = array();
    		foreach ( $terms as $term ) {
    			$su_event_cats[] = $term->slug;
    		}
    		$eventCat = join( ", ", $su_event_cats );
    		//echo $su_on_cat;
    	}
    
    //TEST-VARS
    	/*echo "startTime".$startTime."<br>";
    	echo "endTime".$endTime."<br>";
    	echo "startDay".$startDay."<br>";
    	echo "endDay".$endDay."<br>";
    	echo "dateNTime".$dateNTime."<br>";
    	echo "eventCat".$eventCat."<br>";
    	echo "eventTitle".$eventTitle."<br>";
    	echo "eventUrl".$eventUrl."<br><hr>";*/
    //DESIGN
    	//echo "isReo= ".$isReo;
    	if($isReo==1){
    		//expand reoccuring output
    	$returnReoccuringEvents.='<div style="width:90%; margin:6px auto; padding:6px; border: 1px dotted #fff; "><h3><a title="'.$eventTitle.'" href="'.$eventUrl.'"><strong>'.$eventTitle.'</strong></a></h3>'.$dateNTime.'</div>';
    	}else{
    		//expand single event output
    	$returnSingleEvents.='<div style="width:90%; margin:6px auto; padding:6px; border: 1px dotted #fff; "><h3><a title="'.$eventTitle.'" href="'.$eventUrl.'"><strong>'.$eventTitle.'</strong></a></h3>'.$dateNTime.'</div>';
    	}
    	endforeach;
    
    	$returnSingleEvents.="</div>";
    	$returnReoccuringEvents.="</div>";
    	//Reset post variable
        $post = $temp;
    endif;
    echo "<h3>actual Events</h3>".$returnSingleEvents;
    echo "<h3>reoccuring Events</h3>".$returnReoccuringEvents;
    ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic