Hello all,
Trust everyone is keeping safe. I am having some trouble writing a query hook for AdvSearch. I have a multi-list tv “animal” with an output delimiter “||” that I want to search with AdvSearch. In this example, I’m using a textarea to allow the user input what they would like to search for. They can use the words “AND” or “OR” to filter what they are searching for.
I have 4 resources with tv “animal”. Provided below are the values within each resource.
Resource 1: dog,cat,bird
Resource 2: cat,dog,fish
Resource 3: cat,bird,fish,dog
Resource 4: dog,turtle
The user tries searching for cat AND dog, the results must only return resources that have “cat” AND “dog” within the animals tv. I tried using different combination of AdvSearch queries and I didn’t get any results. However, I got the “cat” OR “dog” condition to work.
Here in my setup. I’m using Formit to post my Advsearch Results Page. I wrote a hook that searches for “AND”/“OR”. If it finds “AND” in the hook->getValue(“animal”), it replaces “AND” with “,”. If it finds “OR”, it explodes every instance of “OR”. Afterwards, I set Formit “redirectParams” to the toJSON($hook->getValues) and redirect to my search results page.
Therefore, for the “AND” search, my $_GET[“animals”] is a string (e.g value = cat, dog) and my “OR” $_GET[“animals”] is an array. Like I said, the “OR” query appears to be working $andConditions[‘tv.animals:REGEXP’] = ‘animals’ but I can’t figure out the “AND” condition
I tried the following
$andConditions[‘tv.animals:REGEXP’] = ‘animals’
$andConditions[‘tv.animals:IN’] = ‘animals’
$andConditions[‘tv.animals:FIND:||’] = ‘animals’
$andConditions[‘tv.animals:LIKE’] = ‘animals’
Nothing hasn’t work. I’m hoping someone out there is familar working with AdvSearch or proficient with MYSQL. Apologies for the super long post but I’m trying to be as clear as possible. Any help will be appreciated.