When I started with MODX (about 8 months ago) I used the IF-extra for processing some code.
After I while I discovered the "
Output Modifiers" which basically does exactly the same, but without the use of an extra.
OLD:
[[*id:is=`6`:or:is=`10`:then=`[[!ProcessSnippet]]`:else=`[[$DoThisChunk]]`]]
but after reading
this blog post by the great opengeek I realised that this formatting is better:
NEW:
[[[[*id:is=`6`:or:is=`10`:then=`!ProcessSnippet`:else=`$DoThisChunk`]]]]
Now the conditional is applied and for example if ID = 6 is true the result will be [[!ProcessSnippet]]... hey a snippet tag! Great, let parse that!
In the first example the ProcessSnippet & $DoThisChunk are parsed, after that the conditional is applied. So takes more time and resources...
Nowadays if I use a condtional or Output Modifier I always use this method, even if there is only one result
OLD:
[[*id:is=`6`:then=`[[!ProcessSnippet]]`]]
NEW:
[[[[*id:is=`6`:then=`!ProcessSnippet`:else=`-NothingToProcess`]]]]
So if the conditional does not apply the result will be a remark/code comment, not processed by modx: [[-NothingToProcess]]
If it does apply the result will be a snippet that gets processed.
Read
Jason's blog-post if this still doesn't make sense to you....
Cheers
Michiel
[ed. note: mintnl last edited this post 11 years, 5 months ago.]