This Plugin allows CakePHP to interact with the Mailchimp API. Currently I am in the first stages of developing this plugin and as of now it can only Subscribe a user. Unsubscribe, should be coming soon. However, future version will include much more, like an admin backend where you can view subscribers, send newsletters from you backend, etc. That is the plan, time permitting....
This plugin works with CakePHP 2.0, Mailchimp API 2.0 and it also takes advantage of Bootstrap 3.0.
To see a demo of this plugin in action, simply visit http://www.akkaweb.com
and on the header section you will see the newsletter form.
- Download Plugin from this page
- Copy the content of this plugin into the
APP/Plugin/Mailchimp
- Load it into CakePHP using
CakePlugin::load('Mailchimp', array('bootstrap' => false, 'routes' => false));
- Add the following into the
Config\bootstrap.php
file
Configure::write('Mailchimp.apiKey', 'YOUR API KEY');
Configure::write('Mailchimp.default_list_id', 'DEFAULT LIST ID');
Configure::write('Mailchimp.ssl_verifypeer', 'FALSE');
Configure::write('Mailchimp.update_existing', 'TRUE');
Configure::write('Mailchimp.send_welcome', 'TRUE');
- You can use the predefined form element files (APP/Plugin/Mailchimp/View/Elements/), which uses
Bootstrap 3.0
by doing the following:
Add <?php echo $this->element('Mailchimp.ajax-subscribe-form', array('id' => 'xxxxxxxx')); ?>
into your view file, where you want your form to appear. Optionally you can pass in your newsletter id
as depicted above. If you only have one newsletter, you can simply assign the newsletter ID in your bootstrap
as explained above.
Add <?php echo $this->element('Mailchimp.subscribe-form', array('id' => 'xxxxxxxx')); ?>
into your view file, where you want your form to appear. Also, if you only have one newsletter, you can simply assigned the Newsletter ID in your bootstrap
as explained above.
- If you choose not to use the preset element form files, you can create your own form as long as you include
action="/mailchimp/mailchimp/subscribe"
andmethod="post"
. Also you need to have ahidden <input> field
, where you can include your Newsletter Id. This is optional as you can assign your Id in the bootstrap.php file as explained above.
That is pretty much all you have to do to have this working.