Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
I have done some searching but still am having an issue getting this to function.

When I run this code, the mail company API errors out with no message body. Which is the $contact_form_template variable in the sendMailAPI function.

If I place a line of code right after cms:php like:
$contact_email_template = 'This is the email body';

To give couch the variable it needs, it works. At the top of the page, I have an include for the global file (contents functions, other settings used throughout site outside of couch, including the contact template) then an include for couch cms.

<cms:pages masterpage= recipients.php'>
<cms:show_repeatable 'contact-form'>
<cms:php>
sendMailAPI('<cms:show email />', 'contact@domain.com', 'From Name', 'Contact Form Subject', $contact_email_template);
</cms:php>
</cms:show_repeatable>
</cms:pages>
$contact_email_template is unknown at the moment. <cms:php>echo $contact_email_template; </cms:php> will show nothing as well. Try to switch places of require_once on top of template.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I found the fix.

I just needed to add after <cms:php>

global $contact_form_template;

Then it worked and pulled the template.:)

I tried to go back a few times to remove my post or even find it to post but it seems to go through an authentication period.
Thanks for posting the fix. If you still want to delete your post, let me know.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I don't think we should delete this post. I'm sure it will help someone trying to work with <cms:php> tag in the future. The use of 'global' is very often the only change one requires to make while porting existing PHP code into <cms:php> tag.
5 posts Page 1 of 1