Help Desk

Event count and smart filtering

  • Posts: 20 Topics: 10
    | Permalink

    Hi there,

    I have two questions if you don’t mind.

    1. Is it possible to add an event count to the filters on the filter bar? Much like adding post count to tags or categories.

    2. is it possible to do some kind of ‘smart’ filtering. For explicate if “category 1” is selected then the rest of the filters would only show selections that would result in 1 or more events?

    Regards,
    Chris.

    Posts: 18133 Topics: 17 Answers: 973
    | Permalink

    Hey there Chris,

    Apologies for the delay: my last reply appears to have vanished into the ether.

    At any rate, the first thing I need to emphasize here is that we can only offer limited support for custom development questions like this one. With that said, I’d be happy to provide some notes in the hope of pointing you in the right direction 🙂

    1. Is it possible to add an event count to the filters on the filter bar? Much like adding post count to tags or categories.

    Absolutely!

    However, you need to be aware of the following “bear trap”: when filters are applied or when a visitor pages forward the list of events is updated via ajax (ie, without a full page reload).

    That’s important because the Filter Bar itself – if this is where you embed the event count – is not reloaded during this process. For that reason, you would need to determine a way of dynamically updating the event count in these situations as well as adding the count when the page is first loaded (ie, without ajax).

    • The ajax-success.tribe (JS) event can be used to trigger an update following ajax updates
    • The tribe_events_ajax_response (PHP/WordPress) hook can be used to send information like an event count to the browser within an ajax response
    • For regular ‘static’ page loads you will probably want to make use of a template override to add this information

    2. is it possible to do some kind of ‘smart’ filtering. For explicate if “category 1” is selected then the rest of the filters would only show selections that would result in 1 or more events?

    Certainly possible, but quite an involved customization with potentially serious performance considerations to be mindful of:

    • For each filterable aspect of an event, you will need to traverse all available events to see which facets are still applicable, each time a filter is applied or removed
    • Unless you add additional constraints, you will also need to look ‘backwards’ at past events, as ordinarily users can also page back into the past

    Again, those are just rough notes – we’re not going to be able to get into the fine detail for changes like this. If you do need deeper support, though, there are plenty of folks out there who probably can assist further 🙂

    Thanks again and good luck with the project – let me know if there’s anything else I might be able to provide guidance on.

    Posts: 20 Topics: 10
    | Permalink

    Thanks for your help in pointing me in the right direction.

    Posts: 18133 Topics: 17 Answers: 973
    | Permalink

    You’re welcome 🙂

    Posts: 65
    | Permalink

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

    | Permalink

The topic ‘Event count and smart filtering’ is closed to new replies.