Combing AND and OR conditions with getResources tvFilters?

828 views Asked by At

I am combining a form and PHP to create a kind of search.

I am using getResources' tvFilters to show the results of the search, eg:

echo '[[!getResources? &parents=`[[42]]` &tpl=`NewProdTpl` &includeTVs=`1` &includeContent=`1` &limit=`99` &tvFilters=`' . $filters .'`]]';

This works somewhat. But I need to figure out a way to use combined AND and OR conditions, like in SQL, eg:

SELECT supplier_id
FROM suppliers
WHERE (name = 'IBM')
OR (name = 'Hewlett Packard' AND city = 'Atlantic City')
OR (name = 'Gateway' AND status = 'Active' AND city = 'Burma');

Obviously I have tried using brackets like:

$filters = '(Type==Forklift),(Brand==Iseki||Brand==Kubota)';

But I have had no luck.

Would anyone know if there is a way to achieve this?

1

There are 1 answers

0
TheMistaC On

I don't think tvFilters needs brackets, have you tried this (OR delimiter first):

$filters = 'Brand==Iseki||Brand==Kubota,Type==Forklift';

You could also try adding a wildcard:

$filters = 'Brand==%Iseki%||Brand==%Kubota%,Type==%Forklift%';