Support

Home Forums Event Espresso Premium EE4: Table Add On – multi-day datetimes vs multiple datetimes

EE4: Table Add On – multi-day datetimes vs multiple datetimes

Posted: April 4, 2016 at 6:59 pm


eddy@mibeachclub.com

April 4, 2016 at 6:59 pm

Hi there,

This is somewhat in reference to one of my earlier posts (https://eventespresso.com/topic/showing-start-and-end-time-on-espresso_my_events-ticket-table/#post-196833).

I have two iterations for the table add-on. Some events are multiple days so should be displayed as Mon – Fri. And some events have 2 datetimes and I’d like to display it as Mon & Wed. I’m not sure how to set up the conditional to check for this. This is what I have so far (note that I set up a conditional already for when an event is on just one day – I wanted the display to be slightly different. I think I have this right so I’m not asking about that part):

<?php if( $first_datetime->start_time('M j', ' ') == $last_datetime->end_time('M j', ' ') ): // if it's on the same day ?>
				<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php espresso_event_date('F j', ' '); ?> (<?php espresso_event_date('l', ' '); ?>)</td>
			<?php else: ?>
				<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php espresso_event_date('M j', ' '); echo ' - '; espresso_event_end_date('M j', ' '); ?> (<?php espresso_event_date('D', ' '); echo ' - '; espresso_event_end_date('D', ' '); ?>)</td>
			<?php endif; ?>

Thanks


Tony

  • Support Staff

April 5, 2016 at 3:46 am

Hi there,

For this your going to need further customization than a conditional check on the datetime values, you’ll need to count the amount of datetimes and decide what to do from there.

The event table add-on already pulls in all upcoming datetimes, so you can then count how many datetimes you have and do different outputs depending on the count.

$datetime_count = count($datetimes);

if ($datetime_count > 2) {
	//more that 2 datetimes - 'Mon-Fri'

} elseif ($datetime_count == 2) {
	
	//Check if datetimes are on the same day
	if( $first_datetime == $last_datetime) {
	
		//same day datetimes
	
	} else {
	
		//different day datetimes - 'Mon & Wed'
	
	}

} else {
	//single datetime
}

It won’t work for all use cases, for example if you use 3 datetimes to split a single event to allow more registrations on a single event (say you have multiple sessions within a single event) it will not work with the above but should work for the events you mentioned.

Does that help?

The support post ‘EE4: Table Add On – multi-day datetimes vs multiple datetimes’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso