Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[Resolved] Using combined and/or in txp:evaluate
Is it possible to do something like:
<txp:evaluate query='<txp:variable name="somevar" /> > 0 and <txp:variable name="somevar" /> > <txp:variable name="some_other_var" />'>
Do stuff
</txp:evaluate>
If so. What’s the syntax? Do I need lots of parentheses or are there and() and or() functions I need to employ? Not finding much in the way of definitive help on the web, and my tests are going wonky.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: [Resolved] Using combined and/or in txp:evaluate
The syntax looks ok, at least this works for me:
<txp:variable name="somevar" value="2" />
<txp:variable name="some_other_var" value="1" />
<txp:evaluate query='<txp:variable name="somevar" /> > 0 and <txp:variable name="somevar" /> > <txp:variable name="some_other_var" />'>
yep
<txp:else />
nope
</txp:evaluate>
Might it be that you need to add escape="integer" or float to your variables ?
Offline
Re: [Resolved] Using combined and/or in txp:evaluate
etc wrote #343359:
Might it be that you need to add
escape="integer"orfloatto your variables ?
Ahaaaaa, maybe. I’m dealing with prices, so that may be throwing it into disarray. Thank you, I’ll try that.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: [Resolved] Using combined and/or in txp:evaluate
Yeah, also helps if I get the logic right *facepalm*. A combination of integerising and using the proper check has got it working. Simpler than I thought. Thank you.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline