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):
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?
Viewing 1 reply thread
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.
Support forum for Event Espresso 3 and Event Espresso 4.