Support

Home Forums Event Espresso Premium EE4 Upcoming Event Widget

EE4 Upcoming Event Widget

Posted: June 3, 2015 at 12:44 pm

Viewing 14 reply threads


Gilda Taffet

June 3, 2015 at 12:44 pm

Hi,

I have been able to change the look of the Upcoming Events widget via CSS tweaks but there is one thing that I have not been able to figure out: I would like to have the title “Upcoming Events” link to a different page than the default event archive page. Where should I be looking to modify that function? Thanks for your help, Gilda


Lorenzo Orlando Caum

  • Support Staff

June 3, 2015 at 2:24 pm

Hi Gilda, you can register a new customized version of the widget. Here is an example on how to customize the upcoming events widgets for Event Espresso 4:

https://eventespresso.com/topic/attempting-to-customize-upcoming-events-widget-no-widget-php-available/#post-102681


Lorenzo


Gilda Taffet

June 3, 2015 at 2:41 pm

Hi Lorenzo,

I will do that, thanks. I was wondering which line of code in the widget causes that upcoming Events title to link to the archive page?


Gilda Taffet

June 3, 2015 at 2:45 pm

ah, never mind… I found it, wasn’t looking far enough down in the code… thank you! GT


Gilda Taffet

June 3, 2015 at 3:00 pm

On the same subject: This is actually what I was trying to do before trying to change that title url to point to a different page:
I set up the Event List page per the option suggested in the General Settings (“If you would still like your events on a page like in Event Espresso 3.1 or earlier, simply create a page and place a shortcode to display them on the page”). If I want that custom archive page that i created to be the default archive page, can I change this function in the EEH_Event_View.helper.php file: public static function event_archive_url() {
return get_post_type_archive_link(‘espresso_events’);
}
so that ‘espresso_events’ is replaced with the name of my custom archive page or is that not a good idea?


Lorenzo Orlando Caum

  • Support Staff

June 3, 2015 at 3:31 pm

Hi Gilda, changing the URL in your custom upcoming event widget will have it point to the new URL instead of the default events archives page which is similar to example.com/events/:

http://cl.ly/image/3g2C2L142x3t


Lorenzo


Gilda Taffet

June 9, 2015 at 5:59 pm

Hi Lorenzo,
I followed the directions you recommended (https://eventespresso.com/topic/attempting-to-customize-upcoming-events-widget-no-widget-php-available/#post-102681) and made a site specific plugin with the custom upcoming widget code in it (with the new url for the title link). The Customized widget shows up in the widget area but when I use it in a sidebar, it behaves like it is being overridden by the original Upcoming Events widget however.

I tried unregistering the original widget using this code in the child theme’s functions:
// UNRegister the original EE widget

function remove_original_ee_widget() {
unregister_widget(‘ee-upcoming-events-widget’);
}

add_action( ‘widgets_init’, ‘remove_original_ee_widget’ );

But, I get the same result…

Any ideas what I am doing wrong or could this also be a weirdness with the way the theme is structured?


Dean

June 10, 2015 at 1:11 am

Hi,

You were almost there. The widget name was wrong, and you needed to set a higher priority (you didn’t have one):

function remove_original_ee_widget() {
unregister_widget('Event_Espresso_Widget');
}
add_action( 'widgets_init', 'remove_original_ee_widget', 100 );

Just make sure that your new widget has a different name other than Event_Espresso_Widget


Gilda Taffet

June 10, 2015 at 1:47 pm

Hi Dean,
I put that unregister code into the child theme’s functions file but the old Upcoming Events widget is still showing up in the widget selection area along with the Custom version and also it is overriding the custom widget functionality. Here is the site specific plugin doc for you to look at in case I goofed that part up:
https://www.dropbox.com/s/bje6z2mycywlmu8/sbfsite_customizations.php?dl=0
Thanks for your brain!


Dean

June 11, 2015 at 5:39 am

Hi,

OK, I got it wrong!

function remove_original_ee_widget() {
  unregister_widget('EEW_Upcoming_Events');
}
add_action( 'widgets_init', 'remove_original_ee_widget', 100 );

That will clear the default widget. Add it to the site specific plugin above the widget code.

Also, remove this if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); from your site specific plugin.


Gilda Taffet

June 11, 2015 at 11:16 am

Hi Dean,
With this edit, the old widget finally went away (so it is now not available in the widget assignment area) and the custom widget shows up as a widget selection, but when I leave admin and view the site, the custom widget does not appear in the sidebars that it is assigned to (blank) and the widget also disappears from the sidebar it is assigned to (in the admin area) when U come back to the admin area… so, something is still amiss… any ideas?

Here is the site specific plugin in it’s current state:
https://www.dropbox.com/s/hlgsl89tcpaciw6/sbfsite_customizations.php?dl=0

(is line 33 correct: “Custom Upcoming Events Widget”? It does not seem to change anything if I remove the word Custom…)


Dean

June 12, 2015 at 1:37 am

OK, seems there was a slight typo in the code

    /**
     * Register widget with WordPress.
     */
    function __construct() {
        parent::__construct(
            'custom-ee-upcoming-events-widget',
            __( 'Custom Event Espresso Upcoming Events', 'event_espresso' ),
             array( 'description' => __( 'A custom widget to display your upcoming events.', 'event_espresso' )),
            array(
                'width' => 300,
                'height' => 350,
                'id_base' => 'ee-upcoming-events-widget'
            )
        );
    }

should read

    /**
     * Register widget with WordPress.
     */
    function __construct() {
        parent::__construct(
            'custom-ee-upcoming-events-widget',
            __( 'Custom Event Espresso Upcoming Events', 'event_espresso' ),
             array( 'description' => __( 'A custom widget to display your upcoming events.', 'event_espresso' )),
            array(
                'width' => 300,
                'height' => 350,
                'id_base' => 'custom-ee-upcoming-events-widget'
            )
        );
    }

Notice the difference in the id_base?

Once change to custom-ee-upcoming-events-widget the widget worked for me.


Gilda Taffet

June 13, 2015 at 1:00 am

Thank you so much, that was the missing piece!

Gilda


Dean

June 15, 2015 at 1:23 am

That’s great!

Anything else I can help with regarding this topic or can I mark it as resolved?


Gilda Taffet

June 16, 2015 at 10:59 pm

It is resolved, thanks very much for your help.

Viewing 14 reply threads

The support post ‘EE4 Upcoming Event 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