WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Event Search form In Sidebar? (12 posts)

  1. AJD
    Member
    Posted 6 months ago #

    The [event_search_form] short code is not working from within a text widget, is there a way to get a event search form in the sidebar?
    Thanks!

    http://wordpress.org/plugins/events-manager/

  2. AJD
    Member
    Posted 6 months ago #

    If there is a built in option to put search in the sidebar within Events Manager I haven't been able to find it.

    I created a custom Events Search Widget. I'm using it in functions.php, but it could also go into a custom plugin.

    It is useful to create custom templates for events-search.php, scope.php, and other search templates so they look better in the sidebar.

  3. angelo
    NetWebLogic Support
    Posted 6 months ago #

    maybe you can try to use wordpress plugin to enable shortcode in Text widget and then use EM shortcode [event_search_form ajax=1]

  4. AJD
    Member
    Posted 6 months ago #

    Thanks, the sidebar widget is works, so I imagine a shortcode plugin would work as well. However, the ajax functionality does not work from the sidebar. It looks like it is attempting to apply the ajax functions to the sidebar content rather than the main content.

  5. philipjohn
    Member
    Posted 6 months ago #

    The shortcode wasn't expected to be used in a widget as that's not something WP allows as standard so it may be that the required javascript isn't loaded.

    Do you see any Javascript errors when trying to use the widget?

    Thanks

  6. AJD
    Member
    Posted 6 months ago #

    My widget is calling the shortcode like this:

    echo do_shortcode('[event_search_form ajax=1]');

    The ajax is actually working, but it inserts the results into the sidebar, rather than the main window. There must be a simple tweek to the javascript to tell it which div to ajaxify. I'm not sure where that is or how to adjust it.

  7. caimin_nwl
    NetWebLogic Support
    Posted 6 months ago #

    The AJAX search function targets em-search-wrapper but as far as I know there's no way to override that without hacking core files.

  8. AJD
    Member
    Posted 6 months ago #

    Where is the JavaScript that runs the search? I could deregister it and register a new version that targets the content area.

  9. angelo
    NetWebLogic Support
    Posted 6 months ago #

    have you tried to just use [event_search_form] ?

  10. AJD
    Member
    Posted 6 months ago #

    Yes it looks like the search function targets the .em-search-wrapper and outputs the results into: .em-search-ajax.

    I hoped it would be as simple as adding those classes into some divs in my template's main content area, but that doesn't work.

    However, since [event_search_form] is functional without ajax in the sidebar widget I will leave it at that.

    cheers

  11. AJD
    Member
    Posted 6 months ago #

    Update:
    When I changed the shortcode to: [event_search_form], now the ajax is working. It inserts the search results into my main page template where I have added:

    <div class="em-search-wrapper">
    <div class="em-search-ajax">
    </div>
    </div>

    I am curious if this will interfere in cases when the search form is also included in the page, or if the ajax function just targets the first ".em-search-ajax" class that it finds.

    EDIT:

    Yes it works! I just had to add the ".em-search-ajax" class to my theme's 'post_class' function. Now the ajax replaces whatever content is in the page with the search results. ".em-search-wrapper" is not necessary.

    In functions.php:

    function em_search_post_class($classes) {
    $classes[] = 'em-search-ajax';
    return $classes;
    }
    
    add_filter('post_class', 'em_search_post_class');
  12. AJD
    Member
    Posted 5 months ago #

    Update:
    The .em-search-ajax snippit from above is breaking event and category pagination.

    When clicking page 2 for example it tries to load the next page with ajax and fails to an empty page. (Not a white screen.)

    Back to the drawing board, for now I will disable ajax in the search sidebar widget, since it works fine without it.

    I hope the Events Manager developers release a sidebar search in a future update.

Reply

You must log in to post.

About this Plugin

About this Topic