我有 TYPO3 11.5。 我有一个定制模型“Atto”。 在我的 TCA 配置中,我使用了:
'atto' => [
'exclude' => true,
'label' => 'Atti',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'tx_atto_domain_model_atto',
'MM' => 'tx_atto_domain_model_atto_mm',
'foreign_table' => 'tx_atto_domain_model_atto',
'foreign_table_where' => ' AND (tx_atto_domain_model_modelloatto.sys_language_uid IN (-1,0) OR tx_atto_domain_model_modelloatto.l10n_parent = 0) ORDER BY tx_atto_domain_model_modelloatto.title',
'MM_opposite_field' => 'atto',
'size' => 10,
'minitems' => 0,
'maxitems' => 99,
'fieldControl' => [
'editPopup' => [
'disabled' => false,
'options' => [
'type' => 'popup',
'title' => 'edit',
'module' => [
'name' => 'wizard_edit',
],
'popup_onlyOpenIfSelected' => true,
'icon' => 'actions-open',
'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',
],
],
'listModule' => [
'disabled' => false,
'options' => [
'type' => 'script',
'title' => 'list',
'icon' => 'actions-system-list-open',
'params' => [
'table' => 'tx_atto_domain_model_atto',
],
'module' => [
'name' => 'wizard_list',
],
],
],
],
'behaviour' => [
'allowLanguageSynchronization' => true,
],
],
],
该关系有效,但我看不到与相关内容的关系,它不是双向的。我怎样才能达到我想要的结果? 我假设有一个保存挂钩,但我不知道这是否是正确的解决方案,特别是考虑到工作区。
我想我已经找到了解决方案。 可以通过同一个表的另一个字段来获得双向性。这不是完全相同的事情,但这是我发现的唯一可能性,并且与工作区配合良好
我在 TYPO3 CMS 10 中创建了如下双向关系。这也应该适用于其他 TYPO3 版本。在这种情况下,工匠与事件联系在一起,反之亦然。这就是它的完成方式。
tx_placeholder_domain_model_artisan.php
'columns' => [
'events' => [
'label' => 'LLL:EXT:placeholder/Resources/Private/Language/locallang_db.xlf:events',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_placeholder_domain_model_event',
'foreign_sortby' => 'sorting_foreign',
'foreign_table_where' => 'ORDER BY start_date DESC',
'MM' => 'tx_placeholder_artisan_event_mm',
'autoSizeMax' => 20,
'maxitems' => 999,
'multiple' => true,
'enableMultiSelectFilterTextfield' => true,
],
],
],
tx_placeholder_domain_model_artisan.php
'columns' => [
'artisans' => [
'label' => 'LLL:EXT:placeholder/Resources/Private/Language/locallang_db.xlf:artisans',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_placeholder_domain_model_artisan',
'foreign_table_where' => 'ORDER BY name ASC,first_name ASC,company ASC',
'MM' => 'tx_placeholder_artisan_event_mm',
'MM_opposite_field' => 'artisans',
'autoSizeMax' => 20,
'maxitems' => 999,
'multiple' => true,
'enableMultiSelectFilterTextfield' => true,
],
],
],
ext_tables.sql
CREATE TABLE tx_placeholder_domain_model_artisan
(
events int(11) unsigned DEFAULT '0',
);
CREATE TABLE tx_placeholder_domain_model_event
(
artisans int(11) unsigned DEFAULT '0' NOT NULL,
);
CREATE TABLE tx_placeholder_artisan_event_mm
(
uid_local int(11) unsigned DEFAULT '0' NOT NULL,
uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
sorting int(11) unsigned DEFAULT '0' NOT NULL,
sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);