Support

Home Forums Event Espresso Premium Customize upcoming events widget in EE4

Customize upcoming events widget in EE4

Posted: July 27, 2015 at 6:58 am


Joshua

July 27, 2015 at 6:58 am

Hi,

I switched over from EE3 to EE4 and momentarily still in development state. In EE3 I did some customisations to the upcoming events widget but I know that this has got overhauled in EE4. I found this post http://eventespresso.com/topic/attempting-to-customize-upcoming-events-widget-no-widget-php-available/#post-102681 on how to customise in EE4.

This is what I did in EE3, http://cl.ly/image/3h122K2R323E
and this is how it looks like in EE4, http://cl.ly/image/1t1C3L2K0r1a.

In widgets.php I can’t find any reference to this section:

<li id="ee-event-datetimes-li-7" class="ee-event-datetimes-li">
	<span class="dashicons dashicons-calendar"></span>
	3&nbsp;september&nbsp;2015<br>
	<span class="dashicons dashicons-clock"></span>
	12:00 - 14:00
	<form id="download-iCal-frm-7" class="download-iCal-frm" action="http://develop.letslunch.nl?ee=download_ics_file&ics_id=7" method="post">
		<input class="ee-ical-sbmt" value="" title="Add to iCal Calendar" type="submit">
	</form>
</li>

I need to do something like this:

<li class="widget-event">
	<h4><span class="widget-event-name"><?php echo stripslashes_deep($event->event_name); ?></span></h4>
	<span class="widget-event-date"><i class="fa fa-calendar"></i><?php echo event_date_display($event->start_date); ?></span>
	<span class="widget-event-location"><i class="fa fa-map-marker"></i><?php echo stripslashes($event->venue_name); ?></span>
	<a class="widget-event-link" href="<?php echo $registration_url; ?>"><i class="fa fa-link"></i><?php _e('Schrijf je nu in','event_espresso') ?></a>
</li>

Can anyone help me with this?


Josh

  • Support Staff

July 27, 2015 at 7:59 am

Hi Joshua,

The section of the widget template that displays the dates is where it pulls in either the espresso_event_date_range() or espresso_list_of_event_dates() template tags.


Joshua

July 27, 2015 at 8:17 am

How can I change this template to the example I gave above:

<li class="widget-event">
	<h4><span class="widget-event-name"><?php echo stripslashes_deep($event->event_name); ?></span></h4>
	<span class="widget-event-date"><i class="fa fa-calendar"></i><?php echo event_date_display($event->start_date); ?></span>
	<span class="widget-event-location"><i class="fa fa-map-marker"></i><?php echo stripslashes($event->venue_name); ?></span>
	<a class="widget-event-link" href="<?php echo $registration_url; ?>"><i class="fa fa-link"></i><?php _e('Schrijf je nu in','event_espresso') ?></a>
</li>


Josh

  • Support Staff

July 27, 2015 at 10:36 am

Hi Joshua,

You copy over the html, then any variables and functions from EE3 need to be changed over to their EE4 counterparts. If you look through the code you’ll find equivalents. For example, in EE3, the Event name was:

<?php echo stripslashes_deep($event->event_name); ?>

In EE4, the equivalent is:

<?php echo $event->name(); ?>


Joshua

July 29, 2015 at 9:37 am

I can’t understand why nothing is changing in the front-end?! I’ve clearly set it up alright. These are the steps I took:

      Copied the contents of plugins/event-espresso-core-reg/widgets/upcoming_events/EEW_Upcoming_Events.widget.php
      Changed the classname and ID of the custom widget.

      class custom_EEW_Upcoming_Events  extends WP_Widget {
      
      	/**
      	 * Register widget with WordPress.
      	 */
      	function __construct() {
      		parent::__construct(
      			'custom-ee-upcoming-events-widget',
      			__( 'Custom Upcoming Events', 'event_espresso' ),
      			 array( 'description' => __( 'Custom description.', 'event_espresso' )),
      			array(
      				'width' => 300,
      				'height' => 350,
      				'id_base' => 'ee-upcoming-events-widget'
      			)
      		);
      	}
      In functions included the widgets.php file:
      include( 'includes/ee4/widgets.php' );
      In functions registered the widget:

      // Register and load the widget
      function customEE_widget() {
      	register_widget( 'custom_EEW_Upcoming_Events' );
      }
      add_action( 'widgets_init', 'customEE_widget' );

Changes made to the “Front-end display of widget.” section are not being shown. Can you help me?


Josh

  • Support Staff

July 30, 2015 at 7:23 am

Did you activate your widget in Appearance > Widgets?


Joshua

August 4, 2015 at 8:49 am

Yes I did. Still no luck!

http://cl.ly/image/140E1P0k0D10


Josh

  • Support Staff

August 4, 2015 at 1:52 pm

Can you double check the location where your widget code is loading from and check to see if it’s actually loading? You can add a debug echo statement in there too, to check and see if the code is even executing.


Joshua

August 4, 2015 at 3:16 pm

That worked! http://cl.ly/image/2p2Q1N2N150f

So the code is loading fine.


Josh

  • Support Staff

August 5, 2015 at 11:12 am

Hi Joshua,

At this point I can only give you guesses as to why it’s not working for you. For example, I don’t know where you put the debug code, and where you checked.

One suggestion I can make based on the information you’ve given so far is instead of loading in a widget template, you put the entire widget customization in a plugin file, and activate the plugin. This will ensure everything loads if you’re having trouble with loading the template from another folder or something.

This will also help with troubleshooting because if you still have troubles with your code, you can post the entire plugin file into a github gist and link to the gist here and we can investigate. (please do not post a large block of code directly into the forum thread).


Joshua

August 5, 2015 at 5:06 pm

Hi Josh,

Could you by any chance take a look at the website if I provide you with the FTP credentials?


Lorenzo Orlando Caum

  • Support Staff

August 6, 2015 at 2:02 pm

Hi Joshua, could you try Josh’s suggestion and share your entire code in a gist (https://gist.github.com) or an equivalent online code sharing platform?

Then we’ll try it out on a testing site and share feedback.

Thanks


Lorenzo

The support post ‘Customize upcoming events widget in EE4’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Lorenzo Orlando Caum 4 years, 3 months ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!
[for="input_96_5_3"]
[for="input_96_5_3"]
[gravityform id=96 title=false description=false]
  • This field is for validation purposes and should be left unchanged.
[i]
[i]
[gravityform id=69 title=false description=false]
  • This field is for validation purposes and should be left unchanged.