Great replacement for PHx
Params:
is - processed condition (that compare: how to compare: to compare with)
then - @tpl:chunkname, or any html-code tags MODX
else - @ tpl:chunkname, or any html-code tags MODX
math - consist of a mathematical function in the parameter is
separator - Separator condition in params
is
To the parser did not handle option and then and else, as it is in PHx, call: &then=`@TPL:chunkname` - where chunkname - chunk name, then it will be executed only the desired chunk.
The operators used in the condition
is - equal
not - not equal
>,gt - more
lt - less than
gte - greater than or equal
lte - less than or equal
isempty, empty - check void
not_empty,!empty - check zapolennost
null, is_null - check whether a variable is NULL
in_array, inarray, in - in the presence of an array
not_in,!in - the lack of an array
Doing the math functions:
&is=`[+id+]*10:=:30` &math=`on`
examples of use
1) Per share only need a directory with ID = 5
[[if? &is=`[*parent*]:=:5` &then=`@TPL:akcia`]]
2) Per share only need a directory with ID = 5 or catalog pattern № 7,8,9
[[if? &is=`[*parent*]:is:5:or:[*template*]:in:7,8,9` &then=`@TPL: akcia`]]
3) Per share only need a directory with ID = 5 and only the resource with the pattern number 2
[[if? &is=`[*parent*]:=:5:and:[*template*]:is:2` &then=`@TPL: akcia`]]
4) Per share only need a directory with ID = 5 and only the resource with the pattern number 2 or in other templates but with TV show_akcia = 1
[[if? &is=`[*parent*]:is:5:and:[*template*]:is:2:or:[*show_akcia*]:is:1` &then=`@TPL:akcia`]]
5) Per share only for products with a price in the range of > $ 300 < $ 700
[[if? &is=`[*price*]:>:300:and:[*price*]:<:700` &then=`@TPL:chankname`]]
6) the entries in the multiplicity Ditto 3
[[if? &is=`[+ditto_itteration+]:%:3` &then=`true` &else=`false`]]
7) Output in the multiplicity of records Ditto 3 but by multiplying the
[[if? &is=`[+ditto_iteration+]*2:%:3` &then=`true` &else=`false` &math=`on`]]
8) to print the value of the mathematical expression
[[if? &is=`[+ditto_iteration+]*2` &math=`on`]]
Source code
https://gumroad.com/l/TAqQ
[ed. note: dmi3y last edited this post 11 years, 4 months ago.]