Support

Home Forums Event Espresso Premium Add table view column to display the start date of the first datetime

Add table view column to display the start date of the first datetime

Posted: October 22, 2021 at 11:09 am

Viewing 1 reply thread


infrasolutions

October 22, 2021 at 11:09 am

Currently working on customizing the Event Table View Template to display an extra column in my table. After searching the forum, I understand what I need to do to remove the time from the existing Date column which shows the next upcoming datetime for each event.

These events are classes so, I’d like a column to display the Start Date of the event, basically to show the date of the first datetime for all events, and update the existing ‘Date’ column label to show as ‘Next Date’ (thinking this is only a label change since the functionality already shows the next datetime.

Thanks in advance for your assistance.


Tony

  • Support Staff

October 27, 2021 at 6:47 am

Hi there,

After searching the forum, I understand what I need to do to remove the time from the existing Date column which shows the next upcoming datetime for each event.

That column can also list ALL upcoming datetimes if preferred? Just add show_all_datetimes=true to your shortcode to list them out in that column.

These events are classes so, I’d like a column to display the Start Date of the event, basically to show the date of the first datetime for all events, and update the existing ‘Date’ column label to show as ‘Next Date’ (thinking this is only a label change since the functionality already shows the next datetime.

Ok, so the simplest way to pull the ‘first’ datetime for the event order by start date/time is to use the method that is already in use in the template. It currently uses:

$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, $datetime_limit );

To pull in an array of datetime for the event order by start date/time and based on your shortcode attributes will pull in expired datetimes and either multiple or single datetimes.

The above needs to stay as is for the template to work, but as you also always want to return the first datetime you could add an additional line using that same method like this:

$first_datetime = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, true, false, 1 );

get_datetimes_for_event_ordered_by_start_time takes the event ID, then a true/false value for show_expired (which we set to true), the next arribute is for include_deleted and we set that to false, then limit the number of datetimes returned to just 1.

The above returns and array of datetimes (even just 1 will still be in array) so lets grab the first element from it and pass it back to itself:

$first_datetime = reset($first_datetime);

Now $first_datetime should be an EE_Datetime object for the ‘first’ datetime in the event so you can add it into the output.

Here is an example of doing just that:

https://gist.github.com/Pebblo/cb1a8a96a1cbf96fc68cedfeff0c76b0

Does that help?

Viewing 1 reply thread

The support post ‘Add table view column to display the start date of the first datetime’ 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