I’m not a PHX expert at all (full disclosure: I’ve never used PHX
), but looking at the docs, there’s no "if else" in PHX and the else isn’t really an else, it’s really an else=. T do what you want with just else statements, you’d need the part after the else to be a statement, but it’s not -- it just sets the initial variable equal to something. If you were using a single TV, you could use the PHX select: operator.
It looks to me like you need a snippet (although it should be a *very* simple one). Someone more familiar with PHX may have a better answer.
There may be a non-PHX solution using TVs, although I don’t see it.
I think this would be the snippet you want (more or less):
<?php
$tv1_out = $modx->getTemplateVarOutput('tv1');
$tv2_out = $modx->getTemplateVarOutput('tv2');
if (! empty($tv1_out)) {
$output = 'some html';
} elseif (! empty(tv2_out)) {
$output = 'some other html';
} else{
$output = 'yet some other html';
}
return $output;
?>
You could make this more generic by sending the tv names as parameters in the snippet call like this:
[!SnippetName? &tv1=`tv1_name`!]
$tv1_out = $modx->getTemplateVarOutput($tv1);