ProcessWire - Newsletter
Aus Wikizone
Version vom 19. Januar 2019, 12:12 Uhr von Steff (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „== Links == https://github.com/rolandtoth/pwnl Tutorial https://modules.processwire.com/modules/wire-mail-swift-mailer/ Swiftmailer Integration https://modu…“)
Links
https://github.com/rolandtoth/pwnl Tutorial https://modules.processwire.com/modules/wire-mail-swift-mailer/ Swiftmailer Integration https://modules.processwire.com/modules/wire-mail-branding/ Modul für E-Mail Templates https://modules.processwire.com/modules/wire-mail-mandrill/ Mandrill Integration https://modules.processwire.com/modules/wire-mail-swift-mailer/ Swift Mailer Integration https://github.com/pmarki/ProcessSendNewsletter Modul mit Backend WYSIWYG Editor -> mal anschauen
Allgemein
Ryans Newsletter ist komplett in ProcessWire realisiert.
Snippets
Subscription über Hook für FormBuilder
Beispiel für Sendy
Example usage: a checkbox on a contact form (using Form Builder) for the user to subscribe.
It's used on https://ricardo-vargas.com/contact/
EXAMPLE
A method on _hooks.php. If you don't use Form Builder, use this code on your form page.
$forms->addHookBefore('FormBuilderProcessor::emailForm', function($event) {
$processor = $event->object;
if ($processor->formName == 'contact-form') {
$formData = $event->arguments(1);
$contact_name = $event->sanitizer->text($formData['contact_name']);
$contact_name = substr($contact_name, 0, 30); // limit length further
$contact_name = $event->sanitizer->emailHeader($contact_name);
$contact_email = $event->sanitizer->text($formData['contact_email']);
$contact_email = $event->sanitizer->emailHeader($contact_email);
$processor->emailFrom = $contact_email; //reply to
$processor->emailSubject = 'Message from '.$contact_name;
$form = $event->object->getInputfieldsForm();
$subscribe = $form->get('receive_updates');
$list_id = $form->get('sendy_list_id')->attr('value');
// check to see if they subscribed
if ($subscribe->attr('checked')) {
$success_url = '/contact';
// $fail_url = '/contact?error=1';
$ProcessSendyAPI = wire('modules')->getModule('ProcessSendyAPI');
$ProcessSendyAPI->subscribeInSendy($contact_name, $contact_email, $list_id, $success_url);
} }
});