Support

Home Forums Event Espresso Premium Alter the generated content from widget

Alter the generated content from widget

Posted: January 22, 2014 at 2:21 am


Morten Mouritzen

January 22, 2014 at 2:21 am

Hello guys,

Can i alter the the widget to display the upcoming events?

I want a price added for each event.

Is that possible?


Tony

  • Support Staff

January 22, 2014 at 3:08 am

Hi Morten,

The widget is output using the file event-espresso/templates/widget.php

The price is currently not included within the query so you would need to create a custom query to include this, or you should be able to the the [EVENT_PRICE] shortcode such as:

$event_price = do_shortcode('[EVENT_PRICE event_id=' . $event->id . ' number=0]');

Then echo $event_price in the place’s you want to add the price.

https://eventespresso.com/wiki/shortcodes-template-variables/#event-price


Morten Mouritzen

January 22, 2014 at 3:20 am

Ok thats fine, but.. I want to use the widget that generates the whole list of events.

Example:
——–
outlook – 27. januar 2014
Photoshop (ny) – 1. februar 2014
photoshop – 23. februar 2014

Then what i want is a price added here..

Example:
——–
outlook – 27. januar 2014 – $1250
photoshop – 23. februar 2014 – $1250

Is this possible?


Tony

  • Support Staff

January 22, 2014 at 4:45 am

Yes, that list is generated using the file mentioned above.

However, the query used to pull in the event details does not include the price, so the shortcode must be used.

Open up widget.php, place this on line 83.

$event_price = do_shortcode('[EVENT_PRICE event_id=' . $event->id . ' number=0]');

Then go to line roughly line 131, you should see

<li><a href="<?php echo $registration_url; ?>"><?php echo stripslashes_deep($event->event_name) ?> - <span class="widget-event-date"><?php echo event_date_display($event->start_date) ?></span></a>

Change that line to be:

<li><a href="<?php echo $registration_url; ?>"><?php echo stripslashes_deep($event->event_name) ?> - <span class="widget-event-date"><?php echo event_date_display($event->start_date) ?></span> - <span class="widget-event-price"><?php echo $event_price ?></span></a>

That will now include the price as requested above.


Morten Mouritzen

January 22, 2014 at 5:06 am

Ah i see, i need to edit the widget.php file.

But that will make updates of the plugin bad, since it will be overwritten every time.

hmm.. Is there some sort of solution to this? Or shall i re-write widget.php everytime there is an update?


Tony

  • Support Staff

January 22, 2014 at 5:38 am

Hi Morten,

Once you’ve modified the code, you can then copy the widget.php file to wp-content/uploads/espresso/templates/

That will keep the file ‘update safe’ and prevent Event Espresso overwriting the file with each update.


Morten Mouritzen

January 22, 2014 at 7:27 am

Nice one! ๐Ÿ™‚

Thanks for the help, things are sorted out ๐Ÿ™‚

The support post ‘Alter the generated content from 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