Could we have a single Event calendar entry for events ending early the next day

WordPress Event Management, Calendars & Registration Forums Request A Feature Could we have a single Event calendar entry for events ending early the next day

This topic contains 10 replies, has 2 voices, and was last updated by  David Nathan 9 years ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #15836

    Hi Stephen, thanks for a great plugin.

    Problem: Nearly all my events end at 01:00 – 03:00 the next day.

    If I put the actual ending time, I get Event Calendar entries for the 2 days, which makes the event calendar look horrible with double entries, and therefore much less usable.

    At the moment I make each event end at 23:55, but my customers are understandably not happy with this workaround.

    Could you please put in a “show single day” option for the event, which, if checked, suppresses the entry of the second day in the Event Calendar? This way, events which start before midnight, and that end early the next day will result in a single calendar entry.

    Sorry for making such a trivial request, but it does have a major effect on your Event Calendar usability.

    Cheers, David

    David Nathan
    #15841

    Hi David,

    It’s unlikely this will be implemented as feature – partly because it complicates matters, but also adds additional UI settings which are, for the majority of users, not required.

    However you can implement something similar with a few lines of code. The following checks if the start/end date are different and if the finish time is before 6am. If so, for the purposes of the calendar it cuts out the last day:

    function my_fullcalendar_alter_end_date( $event, $event_id, $occurrence_id ){
    
        $start_ymd = eo_get_the_start( 'Ymd', $event_id, null, $occurrence_id );
        $end_ymd   = eo_get_the_end( 'Ymd', $event_id, null, $occurrence_id );
        $hour      = (int) eo_get_the_end( 'G', $event_id, null, $occurrence_id );
    
        if( $start_ymd != $end_ymd && $hour < 6 ){
            //If start & end date are on different days and end time is before 6am
            //set end date to previous day at 23:59
            $end = clone eo_get_the_end( DATETIMEOBJ, $event_id, null, $occurrence_id );
            $end->modify( '-1 day' );
            $end->setTime( 23, 59 );
            $event['end'] = $end->format('Y-m-d\TH:i:s\Z');
        }
    
        return $event;
    
    }
    add_filter( 'eventorganiser_fullcalendar_event', 'my_fullcalendar_alter_end_date', 10, 3 );
    

    You could change that to use a toggle which you set using the event’s custom fields. But for your context, the above would probably make sense, and not rely on the admin correctly setting the toggle.

    Please note that the calendar is cached, any changes will not be reflected until that cached is cleared (by, for example, updating an event).

    Hope that helps!

    Stephen Harris
    #15843

    Thanks for your prompt response Stephen.

    I have followed your excellent tutorial and created a site utility plug-in. Do I add the code in there?

    Have a great weekend, David

    David Nathan
    #15844

    Yes – a site utility plug-in would be the best place for it. It will also work in your theme’s functions.php.

    Stephen Harris
    #15852

    Hello Stephen,

    I added your mod to my site utility plugin and it works perfectly.

    The result is good on a PC, because the mouse hover panel shows both the start and end times of an event.

    However, on a tablet, the hover panel info is displayed for less than a second, before the event details screen is shown. The event details screen only display the start time of the event.

    Could you help me to show both start and end times in the event details screen?

    Thanks, David

    David Nathan
    #15853

    Hi David,

    Certainly. If you first copy the template event-meta-single-event.php (from event-organiser/templates/ into your theme and then add the line:

    <li><strong><?php _e('End', 'eventorganiser') ;?>:</strong> <?php eo_the_end($date_format); ?> </li>
    

    underneath the lines (~58)

    <!-- Single event -->
    <li><strong><?php _e('Start', 'eventorganiser') ;?>:</strong> <?php eo_the_start($date_format); ?> </li>
    

    If you have recurring events you’ll want to edit also line ~92

    <li> <?php eo_the_start($date_format) ?></li>
    

    So that it reads:

    <li> <?php eo_the_start($date_format) ?>&ndash;<?php eo_the_end($date_format) ?></li>
    
    Stephen Harris
    #15854

    Hi Stephen, thanks for your instant reply.

    I know very little about the internal structure of a WordPress site, so excuse my dumb question:

    I am using the Tiny Forge theme and, for me, there appear to be many candidates for copying your code into.

    Could you tell me which file to add your code to, and would it be of long term value for me to look at how your code could be added to a child theme that I would now need to create for Tiny Forge?

    I have not entered the realm of child themes before.

    Thanks, David

    David Nathan
    #15855

    Hi David,

    You need to copy the above mentioned file from event-organiser/templates/ into the root of your theme (or child theme). So, typicaly it will be alongside such files as single.php and style.css.

    All edits should be made to that file. No other changes should be required.

    Stephen Harris
    #15856

    Hi Stephen,

    Thanks for all your support, help, and encouragement, to get my feet wet with modifying Event Organiser – aided by your extensive help documentation on the site.

    I have even modified line 92 to be:

    <li> <?php eo_the_start($date_format) ?> to <?php eo_the_end($date_format) ?></li>

    Now all is working beautifully.

    Have a great weekend,

    David

    David Nathan
    #15857

    Great :).

    R.e. documentation, if there is anything you feel could improve it please feel free to let me know. Feedback is always welcome!

    Stephen Harris
    #15858

    Your documentation is amongst the best I have seen. It consistently “goes the extra mile”.

    I tweaked event-meta-event-single.php to get a more compact event date format for tablets.

    For completeness, I have documented all my mods below:

    ~line 30
    // Was this: $date_format = $date_format = 'j F Y'; 
    $date_format = 'j F'; 
    }else{
    // Was this: $date_format = 'j F Y ' . get_option('time_format'); 
    $date_format = 'j F ' . get_option('time_format');  
    

    <hr />

    ~line 58
    
  • <?php _e('Start', 'eventorganiser') ;?>: <?php eo_the_start($date_format); ?>
  • <?php _e('End', 'eventorganiser') ;?>: <?php eo_the_end($date_format); ?>
  • // Line added

    <hr />

    ~line 93
    // Was this: 
  • <?php eo_the_start($date_format) ?>
  • <?php eo_the_start($date_format) ?> till <?php eo_the_end($date_format) ?>
  • <hr />

    My very successful “php coding” today has made my day!

    Cheers,

    David

    David Nathan
Viewing 11 posts - 1 through 11 (of 11 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.