Limit Search

Home Forums Calendar Products Events Calendar PRO Limit Search

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #989692
    Michael
    Participant

    Hello,

    I have a list calendar setup. When I use the filter / search by date, (once clicked, the url is “/events/list/?tribe_paged=1&tribe_event_display=list&tribe-bar-date=2015-07-29”) it does indeed filter my events!

    The problem is if I select July 29th, and there are no events on the 29th, it doesn’t return a message saying there are no dates, it instead shows the next upcoming dates.

    Is there a way to change this? It’s a bit confusing for users.

    Thanks,
    Mike

    #989942
    Nico
    Member

    Hi Mike,

    Thanks for reaching out to us! Hopefully this is possible by modifying the ‘list view’ query, let’s jump into it:

    Add this snippet to your functions.php file -located at ‘wp-content/themes/your_theme/’:


    add_action( 'tribe_events_pre_get_posts', 'limit_list_view' );
    function limit_list_view( $query ) {
    if( tribe_is_list_view() or $query->get('eventDisplay') == 'list' ) {
    $eventDate = $query->get('eventDate');
    if( empty($eventDate) ) $eventDate = date('Y-m-d');
    $query->set('end_date', $eventDate . ' 23:59:59');
    }
    return $query;
    }

    That should limit the results in list view to just the selected day in the picker or today’s date if none is selected.

    Please try it out and let me know if it works for you,
    Best,
    Nico

    #990089
    Michael
    Participant

    Hey Nico,

    Thanks so much for your response, the action worked perfectly!

    Basically what I did was create custom buttons, that display 7 days of the current week. For example, each button, I use the PHP date() function to increment the day. Which is why I use the url /events/?tribe_paged=1&tribe_event_display=list&tribe-bar-date=2015-07-27 to filter by day.

    Is there a piece I can add to the URL that will filter the venue by ID or slug as well? In the demo, http://wpshindig.com/events/?tribe_venues%5B%5D=11034, I used the filter to sort. The url chunk: /?tribe_venues%5B%5D=11034 doesn’t seem to work when I add it to my url.

    Thanks for all your help so far and let me know!

    #990530
    Michael
    Participant

    Hey Nico,

    Just wanted to follow up with this, let me know and thanks!

    #990753
    Nico
    Member

    Hi Michael,

    Thanks for your follow-up, and glad that snippet worked well for you! Sorry for the delay on my reply, we don’t work on weekends so Mondays are usually busy for us.

    Your customization sounds interesting, please send us your site URL when it’s ready!

    Regarding the venue filtering, in the WP-Shindig site that’s achieved by the FilterBar add-on. One simple thing to do is to link to the venue page where events taking place there are listed. The URL would be something like: http://your_site/venue/venue-slug/. Adding the ‘tribe_venue’ parameter to the URL you are building will load the venue page.

    I must say building this customization will require developing some custom code (not just a simple snippet) and that is out of our support scope ๐Ÿ™

    That being said I think it’s quite possible to achieve this. You can inspect the query for the venue page, and try to build something similar with a custom query_arg parameter for the venue slug and some patience. Here is the code to inspect the query in a tribe view, it should be a good starting point:

    add_action( 'tribe_events_pre_get_posts', 'show_query' );
    function show_query( $query ) {

    echo '

    ';
    	var_dump($query);
    	echo '

    ';

    return $query;
    }

    Do you think you can use the built-in venue page? Or you’ll rather give the customization a try?

    Please let me know if you have any other follow-up questions,
    Best,
    Nico

    #990774
    Michael
    Participant

    No worries about the delay, thanks for getting back to me!

    Thanks for your response, using the /venue/slug/ worked perfect. When the site launched, I’ll be sure to send it your way.

    • This reply was modified 8 years, 8 months ago by Michael.
    #990916
    Nico
    Member

    That’s great Michael, looking forward to see the site. Glad I could help ๐Ÿ™‚

    Iโ€™ll go ahead and close out this thread, but if you need help with anything else please donโ€™t hesitate to create a new one and we will be happy to help.

    Best,
    Nico

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Limit Search’ is closed to new replies.