I have worked on my table “products” that contains a json column (prd_Tags).
- I pull all the records of my products table (NO OUTPUT)
- Create an arrayList and set the value to my step-1 query
- Clear the arrayList (I just wanted to copy the schema, we don’t need the data)
- I add a repeat with expresion the step-1 query (loop throught the table’s products)
- Set Value tags_Array and gave it the current repeat’s prd_Tags column value
- I create a switch and set it to false (this is to check if the record is already added to the arrayList)
- I add inside the repeat one more repeat to repeat through each product’s tags (JSON)
(here I explain that you could skip step 5 and set now the repeat straight to the prd_Tags column, but just like to see the setValue steps and know what I’m doing) - I add a condition to check when to add the current product to the arrayList.
Ifswitch == false
(the product has not been already added to arrayList) and$_GET.filtertags,contains($value)
(filter contains the current product’s tag) - if the conditions are met add the current repeat’s product to the arrayList
- set the switch to true in order not to add again the same product
- Closing all all repeats, we get the arrayList and this is the final filtered query that we are going to use client-side to list our products
(THIS IS THE ONLY STEP/VALUE THAT HAS OUTPUT ticked)
Now I realized that if no filter is set the arrayList(new query) will be empty…
You can avoid this and return all the records of the table if you add a condition after step-2 and check if filter has value.
Enclose all steps 4-10 inside the if and leave step-11 outside the if statement (so we have in both cases the arrayList to list our records client-side)
I hope it helps