Support

Home Forums Event Espresso Premium EE4 Upcoming Events Widget – Show Events in Alphabetical order

EE4 Upcoming Events Widget – Show Events in Alphabetical order

Posted: August 29, 2014 at 1:29 pm

Viewing 3 reply threads


Jenny Volvovski

August 29, 2014 at 1:29 pm

Hi,
I am trying to alphabetize the events that appear in the widget, instead of having them organized by start date. I still want to exclude expired events.

Please let me know if this is doable.

Thanks,
Jenny


Josh

  • Support Staff

August 29, 2014 at 3:15 pm

Hi Jenny,

It is doable. If you open up the upcoming events widget file, you’ll see where it runs the query. You can change the order_by paramter to 'EVT_name' and it will order the events alphabetically by name. Example code follows:

// run the query
$events = EE_Registry::instance()->load_model( 'Event' )->get_all( array(
    $where,
    'limit' => $instance['limit'] > 0 ? '0,' . $instance['limit'] : '0,10',
    'order_by' => 'EVT_name',
    'order' => 'ASC',
    'group_by' => 'EVT_ID'
));

Please note that if you make this change directly to the plugin file, it will get wiped out on the next update. You can avoid this by cloning the default widget into its own little plugin. I made a copy of the widget and packed it up into a little plugin, which you can get a copy of the code from here:

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

  • This reply was modified 10 years, 3 months ago by Josh. Reason: code formatting


Jenny Volvovski

August 29, 2014 at 3:33 pm

Perfect!

Thanks so much!
Jenny


Josh

  • Support Staff

August 29, 2014 at 5:05 pm

You’re welcome.

Viewing 3 reply threads

The support post ‘EE4 Upcoming Events Widget – Show Events in Alphabetical order’ 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