• Resolved Daedalon

    (@daedalon)


    Referring to 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) 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.
      if ( defined( 'DOING_AJAX' ) ) {
      	$args['scope'] = get_option('dbem_events_page_scope');
      }
    2. 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:

      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);
      }

      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/

Viewing 5 replies - 1 through 5 (of 5 total)
  • thanks, will look into this.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    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

    (@daedalon)

    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

    (@daedalon)

    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)

    (@netweblogic)

    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.