-
Notifications
You must be signed in to change notification settings - Fork 199
@IF @ELSEIF @ELSE @ENDIF
<@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)
It is useful for creating pages with complicated structure such as management screen. Previously, when such a branching process was necessary, it was necessary to create many chunks.
Determine the presence or absence of a value. Therefore, a combination with a modifier is effective.
https://github.com/modxcms/evolution/blob/v1.2/assets/plugins/elementsintree/assets/on_manager_tree_render.tpl
Actual sample
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:[*template:is(0)*] >
[[Heavy_snippet1]]
<@ELSE>
[[Heavy_snippet2]]
<@ENDIF>
If write as above, it only parse either [[Heavy_snippet1]] or [[Heavy_snippet2]]. Therefore, there is no waste.