Quote from: Bruno17 at Jul 28, 2010, 04:33 AM
try
[+phx:if=`[!UltimateParent!]`:is=`9`:then=`{{test_chunk_1}}`:else=`[+phx:if=`[*id*]`:is=`9`:then=`{{test_chunk_1}}`:else=`{{test_chunk_2}}`+]`+]
Time to write that snippet.
[!PickChunk? &up=`[!UtimateParent!]` &id=`[*id*]`!]
<?php
/* PickChunk snippet */
if ($up == '9' || $id == '9') {
$chunk = 'test_chunk_1';
} else {
$chunk = $modx->'test_chunk_2';
}
return $modx->getChunk($chunk);
?>
Actually, you could do it in one line like this:
<?php
return $up == '9' || $id == '9'? $modx->getChunk('test_chunk_1') : $modx->getChunk('test_chunk_2');
?>
I’m not sure which would be faster (probably the second), but either one should be infinitely faster and more efficient than PHX. PHX conditionals are very expensive.
You could also send the names of the two chunks in the snippet call if you want to make it more general.