X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=template.php;fp=template.php;h=697761e2962233e0f080332ceab7366744d3ee6d;hb=7b2c07787abcab33f2e38f1662fc2287befb2794;hp=cbb9466f18d01ef7eed3e17a3a47f7f3a18583d4;hpb=a9dd0d67c9afda25901033e3f1d2e75014416707;p=wfpl.git diff --git a/template.php b/template.php index cbb9466..697761e 100644 --- a/template.php +++ b/template.php @@ -324,6 +324,13 @@ function tem_auto_show(&$value) { return $value; } +# 'empty' sections will be shown only if the corresponding data value is the +# empty string +function tem_auto_empty(&$value) { + if($value === '') return true; + return null; +} + # 'nonempty' sections will not be shown if the corresponding data # value is the empty string function tem_auto_nonempty(&$value) { @@ -331,7 +338,7 @@ function tem_auto_nonempty(&$value) { return $value; } -# 'not' sections will not be shown if the corresponding data +# 'unset' sections will not be shown if the corresponding data # value is not set (opposite of default) function tem_auto_unset(&$value) { if($value === null) { @@ -352,6 +359,27 @@ function tem_auto_evenodd(&$values) { return $values; } +# 'once' sections are shown exactly once if the value is set (and not at all +# otherwise.) This is useful when an array value would otherwise cause the +# section to be displayed multiple times. +function tem_auto_once(&$value) { + if($value === null) return null; + return true; +} + +function tem_auto_once_if(&$value) { + if($value) return true; + return null; +} + +# 'once' sections are shown exactly once if php evaluates the value to false +# (and not at all otherwise.) This is useful when an array value would +# otherwise cause the section to be displayed multiple times. +function tem_auto_once_else(&$value) { + if($value) return null; + return true;; +} +