Quote from: Jorik at Sep 22, 2010, 11:13 PM
I want to filter TV’s by price.
For instance, everything that costs more than $100:
Or even a price range: equal or between $125 and $175:
&tvFilters=`price>=125,price<=175`
Unfortunately, this doesn’t work. Any suggestions for workarounds?
Thanks!
Hi,
I do not know if there is a better way, but here are minimum two ways that you can solve it. The first way is with IF snippet. Let’s say you getResource chunk is simple:
<a href="product">MyProduct price:[[+price]]</a>
You can use IF nested snippet in your chunk like this:
[[!If? &subject=`[[+price]]` &operator=`>=` &operand=`125` &then=`
[[!If? &subject=`[[+price]]` &operator=`<=` &operand=`175` &then=`
<a href="product">MyProduct price:[[+price]]</a>
`]]
`]]
Secound way may be less complicated for review, if You are using custom snippet. Create new snippet call it ifEval:
<?php
$return = false;
$ifeval_str = '';
$ifeval_str = 'if('.$input.') return true; else return false;';
$return = eval($ifeval_str);
if($return) return $content;
And then if your getResource chunk:
[[!ifEval? &input=`[[+price]]>=125 or [[+price]]<=175` &content=`<a href="product">MyProduct price:[[+price]]</a>`]]
In the input parameter, You can use any of the signs of comparison (and other operators) and code that is used inside the ’IF’ function in PHP.