Title: [PATCH] AJAX search
Last modified: August 20, 2016

---

# [PATCH] AJAX search

 *  Resolved [Daedalon](https://wordpress.org/support/users/daedalon/)
 * (@daedalon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/patch-ajax-search/)
 * Referring to [http://wordpress.org/support/topic/plugin-events-manager-ajax-on-search-page](http://wordpress.org/support/topic/plugin-events-manager-ajax-on-search-page),
   which is closed for replies, we tried again to set up AJAX search by adding this
   to wp-config.php: `define('EM_AJAX_SEARCH', true);`
 * Last time we had issues with multilingual ([qTranslate](https://wordpress.org/extend/plugins/qtranslate/))
   category names coming out as a jumble. This worked now without any problem, likely
   due to customizations we had done in placeholders. However, two issues remained,
   of which one we fixed outright and wish to share the patch with you.
    1. The scope used in AJAX search was always ‘future’. Adding this to templates/
       templates/events-list.php makes the one in EM settings be used instead.
    2.     ```
           if ( defined( 'DOING_AJAX' ) ) {
           	$args['scope'] = get_option('dbem_events_page_scope');
           }
           ```
       
    3. The all day text still comes out as “All DayKoko päivä”, even though it should
       be either “All Day” or “Koko päivä”. We could attempt the same placeholder hack
       that seems to have solved the issue for the categories, but we’d prefer to do
       this nice and proper and contribute a patch towards EM core.
        That All day text
       comes from Settings > Formatting > Default event list format: `{all_day}<!--:
       en-->All Day<!--:--><!--:fi-->Koko päivä<!--:-->{/all_day}`. The part in templates/
       templates/events-list.php that prints this text is:
    4.     ```
           if(get_option('dbem_event_list_groupby') ){
           	$args['mode'] = get_option('dbem_event_list_groupby');
           	$args['date_format'] = get_option('dbem_event_list_groupby_format');
           	echo em_events_list_grouped($args);
           }
           ```
       
    5. Where’s the correct place to add the filters that this AJAX events list misses(
       but normal list doesn’t)?
 * [http://wordpress.org/extend/plugins/events-manager/](http://wordpress.org/extend/plugins/events-manager/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/patch-ajax-search/#post-3573573)
 * thanks, will look into this.
 *  Plugin Author [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/patch-ajax-search/#post-3573597)
 * 1. I’ll add this into em-actions.php (search for search_events), same effect.
 * 2. does this happen on normal pages too, or just ajax? if just ajax, you’d probably
   want to run whatever qtranslate function is needed through the filter em_ajax_search_events(
   same place as in 1)
 *  Thread Starter [Daedalon](https://wordpress.org/support/users/daedalon/)
 * (@daedalon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/patch-ajax-search/#post-3573603)
 * 1. Great!
 * 2. Just AJAX. Regular pages work perfectly, but the AJAX ones do something differently
   so that qTranslate isn’t called. I’ll look into em-actions.php’s em_ajax_search_events.
   Thanks!
 *  Thread Starter [Daedalon](https://wordpress.org/support/users/daedalon/)
 * (@daedalon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/patch-ajax-search/#post-3573681)
 * Adding this to our customization plugin **almost** solved that remaining severe
   AJAX search issue:
 *     ```
       // Run Events Manager's AJAX search results through qTranslate
       add_filter( 'em_ajax_search_events', '__', 10 );
       ```
   
 * The multingual parts would now get translated. However, they’d be translated 
   into the default language, not the currently selected one. Same happened also
   when using `qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage` instead of`
   __`.
 * How can we get the language information of the calling page inside the AJAX call?
   With that information I could make a function that queries that information before
   calling `__()`.
 * QTranslate keeps language names in URLs, which it then rewrites. Eg. `en.siteurl/`
   and `siteurl/en/` would get translated into `siteurl/?lang=en` internally (if
   I remember correctly). After knowing where the `EM.ajaxurl` that is used in events-
   manager.js is set, there are a few ways I could try to use that towards a solution.
 *  Plugin Author [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/patch-ajax-search/#post-3573692)
 * search for em_wp_localize_script filter in events-manager.php
 * you can change it there

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘[PATCH] AJAX search’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=1039078)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/patch-ajax-search/#post-3573692)
 * Status: resolved