Forum Replies Created
-
AuthorPosts
-
SarahParticipant
I think I’ve managed to fix this. It looks like there were changes in how custom filters should handle altering the query. I’ve followed the example of the most recent source and filtering now no longer shows past events.
SarahParticipantYes, the problem is the meta_query, because in the parent class method Tribe__Events__Filterbar__Filter->addQueryArgs(), which I assume runs for each custom filter child class, the queryArgs are added very simply, so a meta_query set up by one filter will be overwritten by the next filter called. I thought I just needed to concatenate the meta_query arrays in setup_query_args() in the custom filter child class, but this is self-contained. Concatenating here has no effect, since whatever set is simply overwritten by the core Tribe__Events__Filterbar__Filter class.
I can’t find any details about coding this here: https://theeventscalendar.com/knowledgebase/creating-custom-filters-for-filter-bar/ And I’ve looked at the Pro ‘Additional Fields’ (https://theeventscalendar.com/knowledgebase/pro-additional-fields/) and it makes me wonder if you’re misunderstanding. That’s about adding custom fields. We have our own custom fields system. The issue is how the values of these fields are queried when the filters they’re connected to are applied.
I appreciate that in some respects you can’t help with customisation, but you provide the ability to add custom filters by extending Tribe__Events__Filterbar__Filter, and it’s not at all clear how you allow multiple filters to be applied at once – which would seem to be basic functionality. As far as I can see now, this basic functionality is prevented by how the core filter class is structured. Again, I’m probably missing something, please point it out if so.
SarahParticipantHonestly I think I’m either missing something here, or you’ve created a ridiculous situation. Why would you make it either tricky or impossible to have multiple filters applied at once?
SarahParticipantI’ve switched to Tribe__Events__Filterbar__Filter. However, I’m still struggling with getting multiple filters applied. It’s odd as I’m sure this worked all those years ago when the site was first developed. I’ve just had to re-do a lot of the events stuff to work with a recent update, maybe something got lost in the process. I was hoping that things would be gained in the process, but it seems maybe I’ve solved some problems only to encounter others.
As far as I can see each custom filter is setting up its own query args fine through setup_query_args(). However each filter is adding its args to the WP_Query via addQueryArgs() in the parent class Tribe__Events__Filterbar__Filter. I guess $query->set( $key, $value ); is simply overwriting each filter’s meta_query with the next filter’s value. So at first glance it looks like, the way the parent class is engineered, there’s simply no way to have multiple filters applied at once? I’ve not worked it out yet but it seems like some complex additional coding around the pre_get_posts hook, outside but interacting with the EC filters system, would be necessary. Could you confirm this before I spend time heading down that route?
SarahParticipantIt reduces usability because it’s a slightly unfamiliar interface which is very useful when there’s a great deal of options, but has no extra benefit when there’s only a few options. It’s not prohibitive, i.e. not a critical issue. However, when there’s only a few options and a normal select would work fine, the slight unfamiliarity of being presented with the select2 interface is a slight reduction in user experience.
SarahParticipantThis reply is private.
SarahParticipantThis reply is private.
SarahParticipantThis reply is private.
SarahParticipantThis reply is private.
SarahParticipantThis reply is private.
SarahParticipantThis reply is private.
SarahParticipantThis reply is private.
SarahParticipantThis reply is private.
-
AuthorPosts