2017 © Pedro Peláez
 

typo3-cms-extension tev_mailchimp

Mailchimp integration for your TYPO3 site

image

3ev/tev_mailchimp

Mailchimp integration for your TYPO3 site

  • Friday, June 3, 2016
  • by 3ev
  • Repository
  • 8 Watchers
  • 2 Stars
  • 143 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

TYPO3 Mailchimp Extension

Latest Stable Version License, (*1)

Integrate Mailchimp newsletter subscriptions with your TYPO3 site., (*2)

Contents

Overview

This extension allows you to subscribe FE Users to Mailchimp Lists. Information is kept in sync using the Mailchimp REST API and webhooks., (*3)

The following functionality is included:, (*4)

  • A CLI command to download all Mailchimp lists from your account to the local database
  • BE save hooks to ensure that whenever a user is created or updated in the backend their List subscription preferences are downloaded from Mailchimp
  • Extbase slots to ensure that whever a user is created or updated on the frontend their List subscription preferences are downloaded from Mailchimp Extbase slots are no longer included out of the box due to them being very hard to work with
  • Webhook listeners to ensure that whenever a user's List subscription preferences are updated in Mailchimp they are updated in the local database
  • Services to easily trigger Mailchimp subscribe or unsubscribe requests anywhere in your code

Installation

$ composer require "3ev/tev_mailchimp"

Dependencies

Due to a TYPO3 bug dependencies cannot be added to this project's composer.json. Instead, you must add them to your root composer.json file., (*5)

Please see the suggests config in this package's composer.json for the dependencies you'll need to add., (*6)

Setup and Configuration

Install the extension via the Extension Manager as normal. After the extension is installed, you should access its settings and set your Mailchimp API key., (*7)

Using the Constants Editor, you should then set the 'TEV_MAILCHIMP -> Storage Folder' constant, most likely on your root page template. This is the folder that all Mailchimp lists and subscriptions are stored in., (*8)

Finally, clear your TYPO3 caches and your extension will be ready to use., (*9)

Webhooks

If you want your site to listen to incoming webhooks from Mailchimp (which will help to keep your local list data in sync), you can setup a page and add its URL to your Mailchimp config., (*10)

To setup a page that can listen to webhooks:, (*11)

  • Create a page somewhere in your page tree. This page should not be linked to anywhere on your site
  • Add an Extension Template to it, with the following Typoscript in its setup field:, (*12)

    page < tev_mailchimp_webhook_json
    
  • Add the new page's URL to the webhook config for each Mailchimp list you want to listen to

Then just clear your TYPO3 caches, and you'll be ready to go., (*13)

Changing the Email Field

By default, the extension uses the email field on FE Users to sync email preferences. You can change this by setting the 'FE User email field' in the extension configuration. This should be the lower cased, underscored field name as it is in the database. You may want to do this if, for example, your users use an email address as their username, and you don't use the `email field., (*14)

Changing the Logfile Path

By default, extension logs will be written to typo3temp/logs/mailchimp.log. If you'd like to change this, simply set the 'Logfile path' in the extension configuration. This path should either be absolute or relative to the directory that contains your typo3/ source folder. You can set it to be outside of that directory if you use a ../ prefix., (*15)

You can of course completely change the logging functionality using the core TYPO3 API and setting your own logging config in an ext_localconf.php under the Tev\TevMailchimp namespace., (*16)

Usage

Downloading lists

Firstly, you should download all Lists from your Mailchimp account to TYPO3. You can do this by running the following Extbase CLI command in your TYPO3 installation directory (you'll need to create the cli_lowlevel BE User if you haven't already):, (*17)

$ ./typo3/cli_dispatch.phpsh extbase mailchimp:lists

Once this has been run, you'll be able to see all of the downloaded lists using the List View on the Storage Folder you configured earlier. You can optionally set a custom description on each List, and you'll also be able to see the full list of FE Users subscribed to the list under the Subscribers tab., (*18)

Note: If you're changing lists regularly in your Mailchimp account, you should put this command on a cronjob or TYPO3 Scheduler task., (*19)

Using the MailchimpService

You can easily trigger subscriptions or unsubscriptions for users in your Extbase code by injecting the Tev\TevMailchimp\Services\MailchimpService into your own classes., (*20)

The service provides the following methods for managing subscriptions:, (*21)

subscribeUserToList(FrontendUser $user, Mlist $list, $confirm = false), (*22)

Subscribe the given FE User to the given Mailchimp list. If confirm is true, a confirmation email will be sent to the user from Mailchimp, and they will not be added to the list immediately. This means that the local database won't be updated syncronously, and you'll have to rely on a webhook., (*23)

unsubscribeUserFromList(FrontendUser $user, Mlist $list), (*24)

Unsubscribe the given FE User from the given Mailchimp list., (*25)

subscribeToList($email, $list, $confirm = false), (*26)

Subscribe the given email address to the given Mailchimp list. If confirm is true, a confirmation email will be sent to the user from Mailchimp, and they will not be added to the list immediately., (*27)

unsubscribeFromList($email, $list), (*28)

Unsubscribe the given email address from the given Mailchimp list., (*29)

downloadSubscriptions(FrontendUser $user, $newUser = false), (*30)

Download a user's current subscriptions from Mailchimp to TYPO3. You may want to call this the first time a user registers on your site, or when they change their email address. Setting $newUser to true will slightly improve performance when downloading subscriptions for a new user, (*31)

downloadLists(), (*32)

Download all lists from Mailchimp to TYPO3., (*33)

Each of these methods will trigger an exception if there is a Mailchimp API error, so you should ensure you handle them appropriately., (*34)

Using the MlistRepository

The Tev\TevMailchimp\Domain\Repository\MlistRepository class allows you to fetch list data from the local database. It provides the standard Extbase repository API. Some of the most common methods you'll likely want to use are:, (*35)

findAll(), (*36)

Get all lists from the local database., (*37)

findAllSubscribedToBy(FrontendUser $user), (*38)

Get all lists subscribed to by the given user., (*39)

findAllNotSubscribedToBy(FrontendUser $user), (*40)

Get all lists not subscribed to by the given user., (*41)

Logging

The following events are logged in the system:, (*42)

  • Successful and failed webhook handlers
  • Successful and failed list downloads via the CLI
  • Any Mailchimp API errors

See above for information on changing the logging setup., (*43)

License

MIT © 3ev, (*44)

The Versions

03/06 2016

dev-master

9999999-dev https://github.com/3ev/tev_mailchimp

Mailchimp integration for your TYPO3 site

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

03/06 2016

v1.1.2

1.1.2.0 https://github.com/3ev/tev_mailchimp

Mailchimp integration for your TYPO3 site

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

21/03 2016

v1.1.1

1.1.1.0 https://github.com/3ev/tev_mailchimp

Mailchimp integration for your TYPO3 site

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

21/03 2016

v1.1.0

1.1.0.0 https://github.com/3ev/tev_mailchimp

Mailchimp integration for your TYPO3 site

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

21/03 2016

v1.0.2

1.0.2.0 https://github.com/3ev/tev_mailchimp

Mailchimp integration for your TYPO3 site

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

07/10 2015

v1.0.1

1.0.1.0 https://github.com/3ev/tev_mailchimp

Mailchimp integration for your TYPO3 site

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

08/09 2015

v1.0.0

1.0.0.0 https://github.com/3ev/tev_mailchimp

Mailchimp integration for your TYPO3 site

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires