Filters with external query loops

Hi @Daniele,
query data from an external API is so amazing, but will it be possible to use filters (Bricks native) on this query too ?
For example , I have a list of recipes in my JSON array, there is a key named “difficulty” with values like : easy, medium, difficult.
Can I filter my grid by difficulty ? If I select “easy” in a dropdown for example, only posts with this difficulty are displayed.
If this is possible, this is the absolute grail…

Hey Cedrik! :slight_smile:

Unfortunately, this is not technically possible with the Bricks Filter, as they only work for the WordPress API. Such filtering options in external APIs are always dependent on what the API returns. Therefore, there will be no uniform solution to handle this via a Select field and Ajax.

You can read about what your REST API would need to provide for this here:

A non-Ajax sort and filter logic would be possible via Dynamic Routes, but only through a page reload and, as mentioned, if the REST API supports it.

Thanks for your answer, this totally make sense, I’m aware that it’s really difficult, I’ve been fighting with datatables and server-side processing…
The reload could be in AJAX in order to not reload all the page, and of course it needs to send the right data to the API in order to get the right answer… but maybe this is doable…
Maybe not in Bricks native filters, but Bricksforge filters :slight_smile:
Each filter need to specify the name of the data sent to the API, for example :
I can send this to my API : https://myapi.com/?difficulty=easy
So, in my filter, the var name would be “difficulty” and it will the send the value selected in the dropdown.
Then get the results and reload the query loop in AJAX.
Something like that :exploding_head:

Yes, but developing our own Bricksforge filter system would be really, really complex. It’s also an open box without an end, as users would always want more features for it. I’m cautious about whether to really bring that in. That’s not planned for now. But who knows what the future holds :slight_smile:

Haha right, that’s ok :slight_smile:

1 Like