"Send To A Friend" functionality

The churches we build sites for often want a button in their Newsletters that will allow the recipient to send that message on to one of their friends. The Monk API doesn’t have any built in means of doing this, but with some basic PHP coding it’s easily doable.

I started by using output buffering in the newsletter template to assign the values of the email subject (available by retrieving subject in the getContent method), the current template ($_SERVER[‘PHP_SELF’]), and $_GET[‘nav’] to encoded variables attached to a “Send to Friend” href.

Then I put together a php script at the website that presents a form the recipient can use to fill in their name, their friend’s name and email, and a custom message. The encoded variables are included in this form as hidden input fields. On a successful submission, the variables are decoded and assigned to the same variable names the newsletter template is expecting, and output buffering is used once again to capture the HTML output of the newsletter template.

I use the excellent PEAR Mail_Mime class to handle the sending.

Only thing you’ll want to make sure you do is set a variable in your server-side script that the newsletter template can use to determine if it needs to include monkcms.php, because this file will already have been included.

This looks like an excellent idea. Can you send us an example link?

page 1 of 1

discussions 1 to 2 of 2