Add php in email (setup submit)

juansolos 30 Aug, 2017
Hi,
i try to insert php code in the email as i was doing with cfv5.
Example check existing value :
<?php if(!empty($form->data["address"])): ?>
Adresse : {address} <br/>
<?php endif; ?>

But in cfv6 php in not executed.
Any help

Regards
juansolos 30 Aug, 2017
Answer
2 Likes
I have found a solution. I hope it is the right method.

I creat a logic php event above email event called myphp :
if($this->data["myfield"]  =='myvalue'): $hop='my text';
else : $hop='my other text';
endif;
return $hop;


and in email event
i call it with {var:myphp}

Seems correct

Regards
Max_admin 31 Aug, 2017
Hi Juan,

Correct!

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
juansolos 25 Sep, 2017
Hi,
ok that works but if i have 100fields, i have to creat 100 logic php even to check if the var is empty?

Maybe another easy method?

Regards
Max_admin 29 Sep, 2017
1 Likes
Hi Juan,

There is a way, by passing dynamic parameters to the php function, define the PHP function before the email like this:

if($this->data($this->get("pname"))){
echo $this->get("plabel");
}

Then in your email:

{fn:myphp$pname=field1&plabel=field1}
{fn:myphp$pname=field2&plabel=field2}


And the next update should have a new feature which can provide an easier solution.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.