ProcessWire - Newsletter

Aus Wikizone
Wechseln zu: Navigation, Suche

Links[Bearbeiten]

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
Ghetto Mailer -> Ryans OldSchool Skript / evtl. nicht mehr zeitgemäß, aber gute Inspirationsquelle.

Allgemein[Bearbeiten]

Ryans Newsletter ist komplett in ProcessWire realisiert.


Snippets[Bearbeiten]

Subscription über Hook für FormBuilder[Bearbeiten]

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);


       }
   }

});