Forums

php in email

ernst@volny.cz 29 Jul, 2019
I need to display the text according to the condition.
I will use php:
<?php if( $form->data['kurz'] = 1 ) { ?>
<p> kurz je jedna </p>
<?php } ?>
but I will see it in my email
data['kurz'] = 1 ) { ?> kurz je jedna 
I can't figure out a mistake, please for help
healyhatman 29 Jul, 2019
$this->data("field") not $form->data["field"] (take note of the different bracket types too)

And for the code presented, use a Custom Code block NOT a PHP block
ernst@volny.cz 29 Jul, 2019
I changed the code to[pre]

<?php if( $this->data("kurz") = 1 ) { ?>[br]<p> kurz je jedna </p>[br]<?php } ?>[/pre]
but the result is the same

I don't understand "And for the code presented, use a Custom Code block NOT a PHP block"[br][br]the code is located in the email block.
healyhatman 29 Jul, 2019
Answer
1 Likes
The mail block doesn't do PHP.

Few options:
Put it in a custom code block set to return as var, and use the name of the block in your email as {var:blockname}

Use a switch, set to return as var, with conditions 1 and * in that order.
ernst@volny.cz 30 Jul, 2019
Thank you for your advice, I will try the variable
This topic is locked and no more replies can be posted.