Forums

PHP in EDmailtemplate

Toxmer 11 Jul, 2017
Hello,

first of all great looking new version of CF! I like it, but of course got some questions that i can't solve these days.

1.) PHP code in email template
In CF5 we was able to put PHP code in E-Mail-Template
(i mostly just do a php "include()" in chrono email action and do the rest in a php file, wich chrono takes for sending). But in Version 6 it wont work anymore. I tried the folowwing conditional statements and none of them work (just getting stripped out the mailbody):


<?php if ({data:name}) : ?>
    <p><b>Stand:</b> {data:name}m²</p>
<?php endif; ?>


and also tried:


<?php if ($this->data("name", null)) : ?>  
  <?php echo $this->data("name"); ?>
<?php endif; ?>


None of the above condition is working. For the first one i get the values but the condition is not working.
Isn't it possible to use PHP Code in Mail-Template anymore ?

2) Copy field
I miss the "copy field" and "paste field" buttons or are they gone (designer)?

Thx for helping me out and keep on the good work!
Max_admin 14 Jul, 2017
Answer
Hi Toxmer,

#1- I'm glad you like the new update!🙂

You can use PHP code in a "Custom code" action before the email, then set the "Custom code" to "return var" and use this shortcode in the email: {var:custom_code_name}

#2- Yes, this is not yet available in v6 but its on the todo list.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Toxmer 19 Jul, 2017
Hello Max,

thx for your reply. The problem is that the "return to var" action is in another event. So the next event dosent know the {var:custom_code_name} var setted as return in event before. I tried to write to session but it dosent work. In Session i leave the data provider as "{data:}" i tried also with "{var:custom_code_name}" as data provider for session. but it dosent work.
Toxmer 19 Jul, 2017
ok i solved this with your hint with the session. anyway it was a better solution to directly insert PHP in Email Editor. Now i have got a workaround but hope you will maybe add this again in fuure releases!

THX anyway!!!
Max_admin 19 Jul, 2017
Hi Toxmer,

Its supposed that you place the "Custom code" action which is going to customize the email contents just above the email action in the same event so that the var is available for the email.

And even if the custom code is in another event, you can still reference it but this is not needed here.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Toxmer 19 Jul, 2017
Hello Max,

i have to say that to grab the VAR in another action is not possible (without saving to session)!
I got a custom code with a return called "confirmdata". In the SAME event as teh return i later can access it via: {var:confirmdata}.

But in the NEXT/ANOTHER action i dont got acces. i tried:
{var:confirmdata}
{data:confirmdata}
But nothing brings the confirmdata saved by custom_code return in event before.

I solved it that i write the var:confirmdata in the event where it was setted (first event) to the session and later access it in the other event (second event) via: {session:confirmeddata}

however without session i dont got access to my {var:confirmdata} setted in event before!

Thx anyway🙂
Max_admin 19 Jul, 2017
Hi Toxmer,

Your PHP code inside a "Custom code" should NOT "return", you only have to enable the "return result as var" setting and then you can use that output in subsequent actions using {var:custom_code_name}.

But you can NOT run the "custom code" in the form "load" event then try to get its value in the "submit" event, that will not work without storing the var in session.

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.