Hi all.
I have been frustrated by this for a while, but I'm finally getting around to posting.
When you return a value from a custom output modifier, that is not a string with at least one character, the original output is returned by MODX.
?php
$nowdate = date("Y-m-d");
if ( strtotime($options) < strtotime($nowdate) ){
return $input;
}
else {
$input = "";
return $input;
}
[[*introtext:pub=`01-dec-2015`]]
Will simply print *introtext.
?php
$nowdate = date("Y-m-d");
if ( strtotime($options) < strtotime($nowdate) ){
return $input;
}
else {
// not the space
$input = " ";
return $input;
}
[[*introtext:pub=`01-dec-2015`]]
Will not print anything - as expected.
This seems fine until you want to write conditional modifiers like so (this is an arbitrary example for discussion):
?php
if ( $input === $options ){
return $input;
}
else {
$input = null;
return $input;
}
[[*field:matchcondition=`jp`:then=`Condition matched`]]
Because :then is just seeing the original output returned.
The only way to get around this is to use :is and :isn't to write in a string to check for:
?php
if ( $input === $options ){
return $input;
}
else {
$input = "null";
return $input;
}
[[*field:matchcondition=`jp`:isnt=`null`:then=`Condition matched`]]
Is there a good reason why we cannot just return a false value and have the following clean conditional?
[[*field:matchcondition=`jp`:then=`Condition matched`]]
I realise that this is an incredibly low priority issue, it just seems very odd.