Support

Home Forums Event Espresso Premium show good time format in multi day events without messing up the widget view

show good time format in multi day events without messing up the widget view

Posted: March 11, 2021 at 9:56 am

Viewing 11 reply threads


benzett

March 11, 2021 at 9:56 am

i wanted to show the time on single event pages for multi-day events in a good way and i found this solution:

https://eventespresso.com/topic/date-time-formatting-for-multi-day-events/

i added
function espresso_list_of_event_dates() {
return espresso_event_date_range();
}

to the functions and thought “wow! works great!”

later i found out that it erases the times and dates from the events list in the widget view…

is there any solution for that?

showing the multiday events with online one time still looks totally wrong:
https://www.benediktzeitner.de/veranstaltungen/intensivwochenende-emotionale-gruppenarbeit-meditation-berlin/

thank you!

b


Tony

  • Support Staff

March 15, 2021 at 4:13 am

Hi b,

The solution for this is actually in the thread you linked to but I’ll go over it here.

You can change the datetime output on the single event output by copying the content-espresso_events-datetimes.php template from Event Espresso’s /public/Espresso_Arabica_2014 folder into your WordPress theme.

Then change that copy to use espresso_event_date_range() in place of espresso_list_of_event_dates().

Remove the above fix you used so the widget ca use that function again.

If you don’t have a child theme already you can follow the steps here to create one:

https://developer.wordpress.org/themes/advanced-topics/child-themes/


benzett

March 21, 2021 at 5:15 am

Thank you tony, I did the solution with copying the datetimes.php now.
however, the wrong format still shows in the widget. can i also have a correct format here without messing the format for the single-event template? thank you!


Tony

  • Support Staff

March 23, 2021 at 7:58 am

Did you remove the code you added above?

When using the method I mentioned above, you don’t want to override the espresso_list_of_event_dates() function, so remove this:

function espresso_list_of_event_dates() {
return espresso_event_date_range();
}

If you still have it on the site.


benzett

March 23, 2021 at 8:01 am

i removed it. i ONLY made the changes in the content-espresso_events-datetimes.php file. no changes in the functions.php.

still the date-time in the widget shows up wrong (check the widget on the right side):

https://www.benediktzeitner.de/

How can i show the correct time format there?


Tony

  • Support Staff

March 24, 2021 at 7:33 am

My apologies but I guess I’m misunderstanding the problem here.

The widget is showing the dates/times as it is expected to show them so can you add some more details on what is wrong?


benzett

March 24, 2021 at 11:39 am

the widget is still showing weird times for multiday-events:

“09.04.2021 – 11.04.2021
18:00 – 17:00”

“from 6 to 5” does just not really look acceptable 🙂

How can I correct this?


Tony

  • Support Staff

March 25, 2021 at 4:30 am

Ahh, ok, so that’s a totally different issue from your opening post then?

That’s the default output for the widget, there is an option to switch it to use date range in the widget settings itself:

Dashboard -> Widgets -> {sidebar} -> EE Upcoming Events -> Show Date Range.

If that doesn’t work for you, may I as how else would you prefer the above to be output?


benzett

March 25, 2021 at 4:34 am

not its not a different issue – i explained it in the title and in the first post of the threat.

the new suggestions worked, thank you! however, it erases the little symbols for the date and the time from the widget. is it possible to still keep them?


Tony

  • Support Staff

March 25, 2021 at 4:49 am

not its not a different issue – i explained it in the title and in the first post of the threat.

This is from your opening thread:

later i found out that it erases the times and dates from the events list in the widget view…

is there any solution for that?

Which is a completely different issue to the default DateTime output from the widget not showing how you prefer, unless I’m misunderstanding something here?

the new suggestions worked, thank you! however, it erases the little symbols for the date and the time from the widget. is it possible to still keep them?

You’re most welcome.

Possible, yes, but you’re likely going to need your own version of the Upcoming Events widget which calls your own function to output the datetimes. The widget calls 1 of 2 functions from within EE, if ‘Show date range’ is set to yes, it calls espresso_event_date_range() to output the dates, otherwise it calls espresso_list_of_event_dates().

It is possible to override those functions in a similar way to how you did above and then include whatever output you prefer in them, but it’s going to apply across the site and not just on the widget so I’m not sure if that will work for you?


benzett

April 8, 2021 at 2:56 pm

i just discovered another unfortunate effect of changing the content-espresso_events-datetimes.php:

for single day events, the single event view doesnt show the end time anymore… how can i fix that?


Tony

  • Support Staff

April 9, 2021 at 5:37 am

Hmm, yeah, so for a single event espresso_event_date_range() outputs the earliest DateTime start time.

To fix that you’ll need to copy the espresso_event_date_range() function into your fuctions.php file and then right after this line:

$html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID );

Add something like:

$earliest_datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
if( $earliest_datetime  instanceof EE_Datetime ) {
    $html .=  ' - ' . $earliest_datetime->get_i18n_datetime('DTT_EVT_end', $single_time_format);
}

Which will add the end time onto the end of that output when it’s a single date.

You may need to move away from using the helper functions and create your own function to output the dates across all of the outputs in a way you prefer, but see if the above works for you first.

Viewing 11 reply threads

The support post ‘show good time format in multi day events without messing up the widget view’ 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