Hallo jk1,
danke, das Prinzip habe ich vermutlich verstanden.
Allerdings habe ich Probleme mit dem Callback. Sobald ich diesen in der config.php definiere, funktioniert weder das Anlegen noch das Bearbeiten eines Datensatzes. Im Contao-Backend ist dann außer der Modul-Überschrift in der Hauptspalte nichts zu sehen (DCA wird nicht geladen oder so…)
Hier mein auf das notwendigste gekürzte Code:
config/config.php
PHP-Code:
<?php
/**
* Back end modules
*/
$GLOBALS['BE_MOD']['content']['my_module'] = array
(
'tables' => array('tl_my_module'),
'icon' => 'system/modules/my_module/html/my_module.png',
'callback' => 'MyModule'
);
?>
config/database.sql
Code:
CREATE TABLE `tl_my_module` (
`id` int(10) unsigned NOT NULL auto_increment,
`pid` int(10) unsigned NOT NULL default '0',
`tstamp` int(10) unsigned NOT NULL default '0',
`title` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `pid` (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
MyModule.php
PHP-Code:
<?php
class MyModule extends BackendModule
{
protected function compile()
{
// test
// $this->redirect('contao/main.php?do=my_module&act=edit&id=1');
}
}
?>
dca/my_module.php
PHP-Code:
<?php
$GLOBALS['TL_DCA']['tl_my_module'] = array
(
// Allgemein Konfiguration
'config' => array
(
//'dataContainer' => 'File',
'dataContainer' => 'Table',
'table' => 'tl_my_module',
// 'closed' => true
),
'palettes' => array
(
'default' => '{legend},title'
),
'fields' => array
(
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_my_module']['title'],
'inputType' => 'text'
)
)
);
?>
Gruß
EDIT: Hmm… selbst wenn man es so hinbekommt wie von jk1 bzw. the_scrat vorgeschlagen, ist es doch eher ein "Hack", da man $GLOBALS['TL_DCA']['tl_my_module'[['config']['closed'] = true erst nach dem Anlegen eines initialen Datensatzes setzen kann, oder?
Lesezeichen