Support

Home Forums Event Espresso Premium event location in upcoming events widget

event location in upcoming events widget

Posted: November 26, 2018 at 7:05 am


paintforfun

November 26, 2018 at 7:05 am

Hi,
I want to show location when I display upcoming events from the widget option. I do not want to display description – only location.
How is this possible?
Thanks


Tony

  • Support Staff

November 27, 2018 at 4:41 am

Hi there,

To add details to the widget you’ll need create your own custom version of the widget, add the location to the output using PHP and then use that custom widget in place of the original.

By location do you want the venue name or address?

For venue name you can use espresso_venue_name() for address, espresso_venue_address()

I have an example of how you can create your own custom version of the EE widget here:

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


paintforfun

November 30, 2018 at 8:48 pm

I have added this piece of code: <p>
<label for=”<?php echo espresso_venue_address(); ?>”>
<?php _e(‘Show Event Location:’, ‘event_espresso’); ?>
</label>
<?php
echo EEH_Form_Fields::select(
__(‘Show Event Location:’, ‘event_espresso’),
$instance[‘date_range’],
$yes_no_values,
$this->get_field_name(‘date_range’),
$this->get_field_id(‘date_range’)
);
?>
</p>

I need to customise it to show the events location, what should I change?


paintforfun

November 30, 2018 at 9:00 pm

if ( $show_dates ) {
$date_format = apply_filters( ‘FHEE__espresso_event_date_range__date_format’, get_option( ‘date_format’ ));
$time_format = apply_filters( ‘FHEE__espresso_event_date_range__time_format’, get_option( ‘time_format’ ));
$single_date_format = apply_filters( ‘FHEE__espresso_event_date_range__single_date_format’, get_option( ‘date_format’ ));
$single_time_format = apply_filters( ‘FHEE__espresso_event_date_range__single_time_format’, get_option( ‘time_format’ ));
if($event_location == TRUE) {
$event_location= $event->espresso_venue_address();
}
if ( $date_range == TRUE ) {
echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() );
}

Is this correct? Ive added the code to the query(and also to the above section where you define instances)


Josh

  • Support Staff

December 3, 2018 at 6:58 am

It looks like you’re trying to make customizations to the Widget’s settings panel. You’ll actually need to make the edits the output, which starts on line 346 of the code Tony shared with you.


paintforfun

December 4, 2018 at 8:08 am

Hi Josh,
THanks for your reply ,but can you be more specific with your answer? what exactly do i need to add and where? I am assuming this is a one line code .
Thanks.


Josh

  • Support Staff

December 4, 2018 at 8:17 am

Can you be more specific with your question? What exactly do you want to display, and where? For example, you mention you want to display the location, does that mean you want to display the name of the venue, the address (and what parts of the address), or both the name & address. Also, where do you want that information to be displayed?


paintforfun

December 4, 2018 at 5:42 pm

Sure! thanks for helping.
I am displaying the widget for a mobile view and would like to hide the description (easy) and show the venue name under the time of the event.

Thats it. Sounds easy but I am messing around with this for too long :/ Thanks


Tony

  • Support Staff

December 5, 2018 at 4:21 am

Thats it. Sounds easy but I am messing around with this for too long :/

This is fairly easy to do, but up until now you’ve not given any details of where you wanted to display the details within the widget itself or what actual venue details you wanted to use.

Rather than using the functions I mentioned above for the above, you can use something like this:

$venue = $event->get_first_related('Venue');
if( $venue instanceof EE_Venue ) {
    echo $venue->name();
}

Add that between these two lines:

https://gist.github.com/Pebblo/d0d5f485ae0599e56e20#file-tw_custom_upcoming_events_widget-php-L377-L378

So it will look something like:

}

$venue = $event->get_first_related('Venue');
if( $venue instanceof EE_Venue ) {
    echo $venue->name();
}

if ( $show_desc && $desc ) {

You can wrap the output in p tags (or any other HTML tags) if you prefer.

The above changes you made are incorrect and will need to be removed.

Also, make sure you are now using the ‘Custom Event Espresso Upcoming Events’ in Appareance -> Widgets and not the default one from Event Espresso for the above to work.


paintforfun

December 5, 2018 at 6:25 am

Thanks for your help, Its working as expected.

The support post ‘event location in upcoming events widget’ 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