Re: How do I use an if statement in a template?

"J. Cox" <[email protected]>
Newsgroups gmane.comp.cms.xaraya.knowledge-base
Organization PostNuke
Message-ID <[email protected]>
An "if" statement in PHP is very similar to that in language.  If this
happens, then do this.  In the Xaraya Template System, the same is true,
only with an XML tag instead.  Suppose you want to add a message on
completion of a form, etc using the variable $message.  Within the template
itself you would use:

<xar:if condition="!empty($message)">
    #$message#
<xar:else />
    Do whatever else you wanted to do if the message is not there.
</xar:if>

In simple terms the if statement is set with a condition.  "If this happens,
do this".  In this case, if the variable $message is not empty then display
the message.  The <xar:else /> statement is in plain English "otherwise".

So reading the syntax within the statement would be:

"If the variable $message is not empty, then display the variable message.
Otherwise, display whatever else you wanted to display when the variable
message is not there."

Pay attention to the closing of tags in order to maintain valid XML syntax.
The if tag stays open until close, but the else tag closes immediately
(similar to an image tag).


Reference:  BlockLayout Specs.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.