Event search filter displaying no events until searched

WordPress Event Management, Calendars & Registration Forums General Question Event search filter displaying no events until searched

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #6695

    Hey. Thanks for taking the time to develop this plugin. Has been very helpful and forcing me to look deeper into what I am doing. When I use the following code: [event_search filters=”event_category,event_venue,date”]

    It provides a search function that can be filtered via attributes. When the page is first loaded it displays all of the events until a search is undertaken. Is there a way to have it so that the event area displays no events until a category or attribute is selected ??

    Thanks,
    Jason

    Jason Crowell
    #6696

    Hi Jason,

    You’re welcome 🙂 Yes you can, see this post: http://wp-event-organiser.com/forums/topic/search-form/

    Stephen Harris
    #6697

    Yes thank you I managed to sort it out from that post before. Is there any way that it the filter can be already on a selected category.

    [event_search filters=”event_category,event_venue,date”] Manipulate this code somehow to have it set to display events from a chosen category. The reason being is because I have set up different pages for the different event categories. In having the Tourism events as a category, it would be good if the tourism events are already open below the search bar. I have made it so there is nothing open until the user searches but I thought I would see if it was possible this way.

    Thanks again,
    Jason

    Jason Crowell
    #6711

    Hi Jason,

    You can, but not as easily as simply editing the templates. The query for events, and the mark-up for the filter/search input is all done in the shortcode handler (see includes/shortcodes.php). But you can replace that handler with the following:

    add_shortcode( 'event_search' , 'my_replacement_handler' );
    function my_replacement_handler(){
      //Define you're replacement handler
    }
    

    Note: the file in which you use that code must be included after the original handler is declared (its a case of ‘last one wins’). functions.php should be fine. If its in a plug-in you’ll probably want to include the above on plugins_loaded or init hook.

    The original handler is _eventorganiser_event_search_shortcode_handler(), so you’ll want to copy and modify the contents of that function.

    At the top is the following:

     $input = isset( $_REQUEST['eo_search'] ) ? $_REQUEST['eo_search'] : array();
    

    If $input is empty you could just set the appropriate arguments to the default query. To give you an idea of what $input should look like:

    $input = array(
        's' => '',//search term
        'event-category' => '',//event category slug
        'event-venue' => '',//event venue slug
        'event-venue' => '',//event venue slug
        'venue_query' => array(
             array(
                'key' =>'_city'
                'value' => '', //venue city
             ),
             array(
                'key' =>'_state'
                'value' => '', //venue state
             ),
             array(
                'key' =>'_country'
                'value' => '', //venue country
             ),
        ),
        'event_start_after' => '',//date / relative date
        'event_start_before' => '',//date / relative date
    );
    

    (Although you could just edit the plug-in files, I don’t recommend this: when you update your changes will be lost).

    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.