Forums / Cotonti / Core Labs / Archive / Logic blocks for xtemplate

GHengeveld
#17355 2009-09-30 05:25
I've just added some extra functionality to the XTemplate logic blocks system. With changeset 988 / 989 you can use two new operators, namely HAS and CONTAINS. These can be used to access the PHP functions array_search() and strpos() respectively.

Examples:
<!-- IF {PHP.usr.name} CONTAINS 'test' -->
Your nickname contains the phrase 'test' !
<!-- ENDIF -->

The second example could be used in conjunction with a plugin listing your user subgroups in an array, something like this:
<!-- IF {PHP.subgroups} HAS 'moderators' -->
You are a member of the 'moderators' user group.
<!-- ENDIF -->

UPDATE: I realized that array_search() would be more practical so I updated the HAS operator to use that instead of in_array(). This will make sure it checks the values, not the keys.
This post was edited by Koradhil (2009-09-30 05:47, 14 years ago)