Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

@IF @ELSEIF @ELSE @ENDIF

yamamoto edited this page Sep 24, 2017 · 5 revisions
<@IF:[*template:is(0)*] >
    Template is blank
<@ELSE>
    Template is [*template:templateName*]
    <@IF:[*description:isNotEmpty*]>
        [*description*]
    <@ENDIF>
<@ENDIF>

or

<!--@IF:[*template:is(0)*] -->
    Template is blank
<!--@ELSE-->
    Template is [*template:templateName*]
    <!--@IF:[*description:isNotEmpty*]-->
        [*description*]
    <!--@ENDIF-->
<!--@ENDIF-->

or

<!--@IF:[*template:is(0)*] >
    Template is blank
<@ELSE>
    Template is [*template:templateName*]
    <@IF:[*description:isNotEmpty*]>
        [*description*]
    <@ENDIF>
<@ENDIF-->

(For html editor)

Determine the presence or absence of a value. Therefore, a combination with a modifier is effective.

https://github.com/modxcms/evolution/blob/v1.2/manager/media/style/MODxRE2/welcome.tpl#L56-L61
"or", "and" can be used. also "||" and "&&" can be used.

https://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/

<@IF:[*id:is(1)*] >
    [[Heavy_snippet1]]
<@ELSE>
    [[Heavy_snippet2]]
<@ENDIF>

If write as above, it only parse either [[Heavy_snippet1]] or [[Heavy_snippet2]]. Therefore, there is no waste.

Clone this wiki locally