我尝试在安装自己的扩展程序时向表tx_gridelements_backend_layout添加一些数据行。为此,我使用文件" ext_tables_static + adt.sql"在我的扩展目录中。
但这只有在我删除表并在插入数据之前再次创建它时才有效。但是,那些可能已经存在的所有数据都将丢失。多数民众赞成绝对不是我想要的。我想在现有数据之外添加一些行。
我怎样才能实现这一目标?
另一个问题是,如果某人清除了表,他们如何意识到他们必须从sys_registry表中删除我的扩展并再次安装它,那么所有行都会再次添加?
我认为有更好的方式做这样的事情,或者?
答案 0 :(得分:1)
因此灵魂是安装后信号扩展管理器正在发出的。为此,在我的ext_localconf.php中,我添加了:
if (TYPO3_MODE === 'BE') {
$class = 'TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher';
$dispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class);
$dispatcher->connect(
'TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService',
'hasInstalledExtensions',
'FalkRoeder\\GridelementsFlex\\Setup\\Setup',
'addBackendLayouts'
);
}
和我的班级FalkRoeder / gridelements_flex / Classes / Setup / Setup.php:
class Setup
{
protected $layouts = [
1 => [
'title' => 'Flexbox 50 50',
'config' => 'backend_layout {\r\n colCount = 4\r\n rowCount = 1\r\n rows {\r\n 1 {\r\n columns {\r\n 1 {\r\n name = links außen\r\n colPos = 1\r\n }\r\n 2 {\r\n name = links innen\r\n colPos = 2\r\n }\r\n 3 {\r\n name = rechts innen\r\n colPos = 3\r\n }\r\n 4 {\r\n name = rechts außen\r\n colPos = 4\r\n }\r\n }\r\n }\r\n }\r\n}\r\n',
'pi_flexform_ds_file' => 'typo3conf/ext/gridelements_flex/Configuration/Flexforms/two_column_flex.xml'
]
];
public function addBackendLayouts( $extname = null )
{
if( $extname !== 'gridelements_flex' ) {
return;
}
foreach ($this->layouts as $layout) {
list($row) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('COUNT(*) AS t', 'tx_gridelements_backend_layout', "title = '" . $layout['title'] . "'");
$count = (int)$row['t'];
if($count == 0) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery(
'tx_gridelements_backend_layout',
$layout
);
}
}
}
}