Also bei mir klappt es leider nicht.
Anbei mein Code.
tl_member
PHP-Code:
<?php
/**
* @copyright Matthias Gmeiner
* @author Matthias Gmeiner
* @license LGPL
*/
/**
* Extend palettes of tl_member
*/
$GLOBALS['TL_DCA']['tl_member']['palettes']['default'] = str_replace
(
'website',
'website,mclists',
$GLOBALS['TL_DCA']['tl_member']['palettes']['default']
);
// Hinzufügen der Feld-Konfiguration
$GLOBALS['TL_DCA']['tl_member']['fields']['mclists'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_member']['mclists'],
'exclude' => true,
'inputType' => 'checkbox',
'foreignKey' => 'tl_module.mclists',
'eval' => array('multiple' => 'true', 'tl_class' => 'w50', 'feViewable' => 'true', 'feEditable' => 'true', 'feGroup' => 'newsletter'),
'sql' => "varchar(255) NOT NULL default ''"
);
tl_module
PHP-Code:
<?php
/**
* @copyright Matthias Gmeiner
* @author Matthias Gmeiner
* @license LGPL
*/
/**
* Extend palettes of tl_module
*/
$GLOBALS['TL_DCA']['tl_module']['palettes']['registration'] = str_replace('{account_legend}',
'{mailchimp},mclists;{account_legend}',
$GLOBALS['TL_DCA']['tl_module']['palettes']['registration'] );
$GLOBALS['TL_DCA']['tl_module']['subpalettes']['mailchimp'] = 'mclists';
/**
* Add fields to tl_module
*/
$GLOBALS['TL_DCA']['tl_module']['fields']['mclists'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['mclists'],
'exclude' => true,
'inputType' => 'checkbox',
'options_callback' => array('tl_module_extended','getLists'),
'eval' => array('multiple'=>true),
'sql' => "varchar(255) NOT NULL default ''"
);
use \DrewM\MailChimp\MailChimp;
/**
* Class ConnectMailchimp
*
* Get lists.
* @copyright Matthias Gmeiner
* @author Matthias Gmeiner
* @package Controller
*/
class tl_module_extended
{
function getLists() {
$MailChimpAPI = $GLOBALS['TL_CONFIG']['mcapi'];
if ($MailChimpAPI == '') {
}
else {
$MailChimp = new MailChimp($MailChimpAPI);
$result = $MailChimp->get('lists');
$alllists = $result['lists'];
$listid = array();
foreach ($alllists as $list) {
$listid[$list['id']] = $list['name'];
}
return $listid;
}
}
}