PHP-Code:
$GLOBALS['TL_DCA']['tl_torg_my_network'] = [
'config' => [
'dataContainer' => 'Table',
'enableVersioning' => true,
'sql' => [
'keys' => [
'id' => 'primary',
],
],
'onload_callback' => [
// TODO: better use a service for the callback!
function (\Contao\DataContainer $dc) {
/* $db = \Contao\Database::getInstance(); // db conn
$pid = \Contao\Input::get('pid'); // get parameter
$result = $db->prepare('SELECT * FROM `tl_torg_my_network` WHERE customer_id = 1')
->execute(); */
$objUser = \Contao\BackendUser::getInstance();
if (!$objUser->isAdmin) {
$GLOBALS['TL_DCA']['tl_torg_my_network']['list']['sorting']['filter'] = [['customer_id=?', $objUser->customer_id]];
} else {
$GLOBALS['TL_DCA']['tl_torg_my_network']['list']['sorting']['panelLayout'] = 'filter,search,limit';
}
},
]
],
'list' => [
'sorting' => [
'mode' => 2,
'fields' => array('customer_id',),
'format' => '%s',
'panelLayout' => 'search,limit'
],
'label' => [
'fields' => array('member_id:mm_torg_member.fullname', 'member_id:mm_torg_member.company', 'customer_id:mm_torg_customer.company'),
'format' => '%s %s %s',
'showColumns' => true
],
'operations' => [
'edit' => [
'href' => 'act=edit',
'icon' => 'edit.svg',
],
'powerteam' => [
'icon' => 'blitz.svg',
'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.togglePowerteam(this,%s)"',
'button_callback' => array('tl_torg_my_network', 'togglePowerteamIcon')
],
'active' => [
'icon' => 'visible.svg',
'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleActive(this,%s)"',
'button_callback' => array('tl_torg_my_network', 'toggleActiveIcon')
],
'datapolicy' => [
'icon' => 'paragraph_green.png',
'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleDatapolicy(this,%s)"',
'button_callback' => array('tl_torg_my_network', 'toggleDatapolicyIcon')
],
],
],
'fields' => [
'id' => [
'sql' => ['type' => 'integer', 'unsigned' => true, 'autoincrement' => true],
],
'pid' => [
'foreignKey' => 'tl_torg_my_network.name',
'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0],
'relation' => ['type'=>'belongsTo', 'load'=>'lazy']
],
'tstamp' => [
'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0]
],
'customer_id' => [
'label' => &$GLOBALS['TL_LANG']['tl_torg_my_network']['customer_id'],
'inputType' => 'text',
'filter' => true,
'eval' => ['tl_class' => 'w50', 'maxlength' => 5, 'mandatory' => true],
'sql' => ['type' => 'integer', 'notnull' => true, 'unsigned' => true]
],
'member_id' => [
'label' => &$GLOBALS['TL_LANG']['tl_torg_my_network']['member_id'],
'inputType' => 'text',
'filter' => true,
'eval' => ['tl_class' => 'w50', 'maxlength' => 5, 'mandatory' => true],
'sql' => ['type' => 'integer', 'notnull' => true, 'unsigned' => true]
],
'is_powerteam' => [
'label' => &$GLOBALS['TL_LANG']['tl_torg_my_network']['is_powerteam'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50', 'maxlength' => 1],
'sql' => ['type' => 'integer', 'notnull' => true, 'unsigned' => true, 'default' => 0]
],
'is_active' => [
'label' => &$GLOBALS['TL_LANG']['tl_torg_my_network']['is_active'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50', 'maxlength' => 1],
'sql' => ['type' => 'integer', 'notnull' => true, 'unsigned' => true, 'default' => 0]
],
'privacy_accepted' => [
'label' => &$GLOBALS['TL_LANG']['tl_torg_my_network']['privacy_accepted'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50', 'maxlength' => 1],
'sql' => ['type' => 'integer', 'notnull' => true, 'unsigned' => true, 'default' => 0]
],
'custom_description' => [
'label' => &$GLOBALS['TL_LANG']['tl_torg_my_network']['custom_description'],
'inputType' => 'textarea',
'eval' => ['tl_class' => 'clr', 'rte' => 'tinyMCE'],
'sql' => ['type' => 'text', 'notnull' => false]
],
],
'palettes' => [
'default' => '{my_network_legend},custom_description,is_powerteam,is_active,privacy_accepted'
],
];
Im folgenden geht es um die unter `operations` eingehängten Icons powerteam, active und datapolicy. "edit" funktioniert!
Lesezeichen