JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
added tem_auto_once() and friends
[wfpl.git] / template.php
index cbb9466..697761e 100644 (file)
@@ -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;;
+}
+