Forums

conditional statements in email template?

samoht 11 Aug, 2008
hello all,

I was just wondering if there is a way to use conditional statements in the email template.

For example I have an array {checkbox} that might be empty - I would like to say:

if({checkbox}) {
some html {checkbox}
}

or something like that.

Any Ideas
GreyHead 11 Aug, 2008
Hi samoht,

Yes, but you can't use {field_name} in the 'if (. . .)' line - it has to be $_POST['field_name'] (or the Joomla 1.5 equivalent).

Bob
samoht 11 Aug, 2008
Hi Bob,

I don't mean to be thick, but is this a php condition or html?

would the template look like:

<h3>{forname} {forname2}</h3>
<?php
if($_POST['checkbox']){ ?>
<p>for the amount(s) of, {checkbox} <br>
<?php } ?>
or this custom amount {otheramount}</p>
<p>Total amount charged = ${totalamount}</p>


or would it look like:

<h3>{forname} {forname2}</h3>
<!--[if($_POST['checkbox'])]>
<p>for the amount(s) of, {checkbox} <br>
<![endif]-->
or this custom amount {otheramount}</p>
<p>Total amount charged = ${totalamount}</p>


I assume not the later because those conditions I think are only read by IE?
Or do I just put the condition in there and the chronoengine will parse it as code instead of text??

Thanks for the help
GreyHead 11 Aug, 2008
Hi samoht,

The first code block is the correct style. Essentially, if your have a web-page that ends in .php then it will be processed by the PHP interpreter before being displayed. Anything out side the <?php. . .?> tags is treated as plain html, anything inside the tags is treated as programming code and the output (from echo or print statements) become html.

Hope this helps

Bob
samoht 11 Aug, 2008
I thought that was the case.

Thanks for the help.
This topic is locked and no more replies can be posted.