Content last modified Tuesday 24 August 2021
hop to #bottom
Categories:
Author:
Current version:
0.3b
About It:
Get it:
Rate it:
  • Helpful?
  • 1 Yes
  • 2 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

ptv_if

Had the need for a proper conditional statement the other day; the "else" part of it to be specific. As I didn't feel that creating a plugin checking for a negating condition, I instead wrote a quick conditional construct.

So...basically this is an if / else if / else tag that can be applied on already existing plugins and functions. It is made up of one "parent" tag inside which the conditions are written.

Example:

<txp:ptv_condition>
<txp:ptv_if plugin="mdm_if_category" category="Alpha"> Content specific to Alpha category </txp:ptv_if> <txp:ptv_else> Content for everything else </txp:ptv_if> </txp:ptv_condition>

It also has support for 2 part comparisons of accessible variables, functions or absolute values, although I havent tested that part thoroughly and it currently uses eval() which is a potential security hazard when combined with user input.

The else_if part is purely decorative as if can be used in its place just as well.

My todolist is:

  • Nested statements.
  • Singular boolean tests.
  • Proper comparisons with and, or, xor, groupings.
  • A way to use the plugins in a bit more elegant way.

Best regards
Borisch a.k.a. Petur

Article Request Count:
Initially released:
2005-03-21
Posted here:
21 Mar 2005

You know you want to visit the Archives.
Published with Textpattern