Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 Yesterday 09:34:01

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,595
Website GitHub

[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

#2 Yesterday 19:13:52

etc
Developer
Registered: 2010-11-11
Posts: 5,715
Website GitHub

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

#3 Yesterday 20:09:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,595
Website GitHub

Re: [Resolved] Using combined and/or in txp:evaluate

etc wrote #343359:

Might it be that you need to add escape="integer" or float to 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

#4 Today 08:05:06

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,595
Website GitHub

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

Board footer

Powered by FluxBB