Support

Home Forums Event Espresso Premium Widget templating (add location, change date format, remove line break)

Widget templating (add location, change date format, remove line break)

Posted: February 5, 2015 at 10:01 am


Angie Meeker

February 5, 2015 at 10:01 am

I need to make edits to EE Upcoming Events widget and would like to know where the template for it is located.

Specifically, I need to add the city/state of an event on the same line as the date, remove the time, and change the date format.


Josh

  • Support Staff

February 5, 2015 at 6:16 pm

Hi Angie,

I recommend making a copy of the built in widget via a separate plugin where you can make all your own edits. Here’s some example code you can use as a starting point:

https://gist.github.com/joshfeck/27a285c4285a6c986053


Angie Meeker

February 10, 2015 at 6:04 pm

Hi Josh, Thanks for your help. That worked out well (creating the plugin to edit). I’ve edited line 294 to change the date format to what I’d like:

if ( $show_dates ) {
                                echo espresso_list_of_event_dates( $event->ID(), 'm/d/Y', FALSE, NULL, TRUE, TRUE );

but it’s still showing the time, which I don’t need at all (I only need the event start date). Playing around with the true, false, nulls, does THINGS, but none of the combinations I’ve tried entirely remove the event time.

Also, I can’t find a hint as to how to echo out the venue’s city/state.


Josh

  • Support Staff

February 11, 2015 at 9:40 am

Hi Angie,

It turns out that the parameters set there do not control whether or not the time gets displayed there. What you can do instead is copy the entire espresso_list_of_event_dates() function from the core plugin’s template_tags.php file and paste it into your custom plugin. There you can make your edits.

If you want those edits to apply anywhere espresso_list_of_event_dates() is used in Event Espresso, you can leave the function name as is. If not, you can rename the function to something like espresso_list_of_event_dates_no_times() and change the function call in the widget so it calls your custom function.


Angie Meeker

February 18, 2015 at 1:39 pm

But I would still leave everything in the copied plugin – just add this function to it?

Also, how can I echo the event city and state?


Josh

  • Support Staff

February 18, 2015 at 2:30 pm

Hi Angie,

You leave everything except instead of calling espresso_list_of_event_dates(), you call your new function.

You can echo the event city and site with the following:

foreach( $event->venues() as $venue ){
	echo '
' . $venue->city() . ', ' . $venue->state_name() . '
'; }

The support post ‘Widget templating (add location, change date format, remove line break)’ 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