Filter by multiple items in URL

Hey guys.
I have a page that lists countries by a repeat region that takes the list of countries from the bank and shows it with a checkbox. I can filter by a single country when I click on the checkbox or choose in select and the URL looks like this: journeys-teste?country=BRA
What I need is to filter the products by more than one country separated by a comma in the URL. Example: journeys-teste?country=BRA,CHI,ITA. It then returns products that have related country codes in the COUNTRIES field array.
In the database I saved the countries as ARRAY [“BRA”,“CHI”] through tagify.
I already tried to do a server connect with the condition {{$_GET.country.split(’,’)}} to get the URL separated by a comma but I couldn’t. I have also transformed the GET field in server connect into ARRAY.
What am I missing here?

This may help:

1 Like

Hello @Cheese and thanks for the response.
But what I need is to filter by the URL type test?country=ARG,BRA,FRA,ITA. Therefore, all products that have these countries in the field will appear in the result. Some products have only one country but others may have more than one in the COUNTRY field separated by a comma.
I can already filter by a single country but several in the URL separated by commas I cannot.

You will need to replace those commas and URL encode, and then on the server side decode and split as far as I know…? Maybe one of the Team can offer some advice. I’ll admit it is not something we have done nor had the need to do so it is fresh territory for me personally.

1 Like

OK.
Thank you so much again.
I’ll check if anyone on the team can help me find the best way to do this filter.

1 Like

You are welcome. Sorry I’m not much help!

1 Like

Hi. Could you show the database query builder condition where you have done this?
The operator should be IN.

2 Likes

What is the country data type in your products?
Is it a single field, JSON array or a subTable?

1 Like

Hello agian, @famousmag.
This is the field structure in the table. I saved the country codes in a tagify field on the product edit page. Some products only have one country but others have 4 or 5. An array is saved in the field.

I suppose you need a kind of repeat to check that…
I’m trying to remeber where I used it and if there is a better method.

Let me check and get back to you my friend.

*Why some records have the square brackets and others no?

And what exactly type of condition you need?

At least one of the countries to exist in the product countries array or all of them?

“pct_code_pais” column looks wrong.
The values need to be regular string for the query to work, as you have configured it.
Each column should have one value, without the quotes or brackets.

This is assuming the data type of this field is varchar. If not, then this is a different problem.

1 Like

Exactly as @sid says, the best es arg,bra,ita, or use relational tables, then you can use join with , and split with , so you can use the IN option

1 Like

Hello.
This pattern [“AUS”,“ARG”] is how the tagify field is saving to the field. Even if I put AUS,ARG in the field, the filter only recognizes one country.
To filter I have a select field that filters only the country code that is in the pct_code_pais field in the table, for example AUS. But if I put AUS,ARG in the same field it no longer returns results. What I need is for it to return results where it has the AUS or ITA code.
I can’t save it as array [“AUS”,“ARG”] ?

Here is a similar workaround I have proposed a few time ago…

And the next post (on the same threat) is the steps explaining…

(But I’m looking forward to see @Heather_Mann’s solution)

1 Like

I’m confused as to why you’re not using the method I showed you in your other post. There’s no need to pass values through the URL, you can pass the values straight to the server connect and it will function just as it does here https://dashboard.triptakers.travel/Testing

1 Like

Not sure if I’m missing something! I thought I had answered the problem on their other post… SELECT type tagify field that takes the list of data from the database

1 Like

Really haven’t paid attention on that one… I apologize

1 Like