我使用扩展新闻和eventnews,所以如果有两种不同的"类型"新闻现在。
新闻扩展附带相关字段和related_from。
我想要还有字段related_event和related_event_from。 原始相关领域应该存储关系到新闻的关系,这些关系只是新闻,新事物关系是新闻事件。 区别在#34; is_event"字段中,因此我将foreign_table_where子句添加到TCA。
为了存储数据,我必须使用相同的mm表。不幸的是,只保存第二个字段,第一个字段不受欢迎。
如何实现两者的存储?我是否需要使用TCA挂钩或是否可以使用标准TCA设置或..?
截至目前我的TCA:
'related' => [
'exclude' => 1,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'LLL:EXT:news/Resources/Private/Language/locallang_db.xlf:tx_news_domain_model_news.related',
'config' => [
'type' => 'select',
'allowed' => 'tx_news_domain_model_news',
'foreign_table' => 'tx_news_domain_model_news',
'foreign_table_where' => 'AND tx_news_domain_model_news.deleted = 0 AND tx_news_domain_model_news.hidden = 0 AND tx_news_domain_model_news.is_event = 0 ORDER BY tx_news_domain_model_news.datetime DESC',
'MM_opposite_field' => 'related_from',
'size' => 5,
'minitems' => 0,
'maxitems' => 100,
'MM' => 'tx_news_domain_model_news_related_mm',
'wizards' => array(
'suggest' => array(
'type' => 'suggest',
'default' => array(
'searchWholePhrase' => TRUE
)
),
),
]
],
'related_event' => [
'exclude' => 1,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'LLL:EXT:dreipc_myadlershof/Resources/Private/Language/locallang_db.xlf:tx_dreipcmyadlershof_domain_model_news.related_event',
'config' => [
'type' => 'select',
'allowed' => 'tx_news_domain_model_news',
'foreign_table' => 'tx_news_domain_model_news',
'foreign_table_where' => 'AND tx_news_domain_model_news.deleted = 0 AND tx_news_domain_model_news.hidden = 0 AND tx_news_domain_model_news.is_event = 1 AND tx_news_domain_model_news.enable = 1 AND tx_news_domain_model_news.sample = 0 ORDER BY tx_news_domain_model_news.datetime DESC',
'MM_opposite_field' => 'related_event_from',
'size' => 5,
'minitems' => 0,
'maxitems' => 100,
'MM' => 'tx_news_domain_model_news_related_mm',
'wizards' => array(
'suggest' => array(
'type' => 'suggest',
'default' => array(
'searchWholePhrase' => TRUE
)
),
),
]
],
答案 0 :(得分:2)
你应该试试MM_match_fields https://docs.typo3.org/typo3cms/TCAReference/ColumnsConfig/Type/Select.html#mm-match-fields
这是一个例子: https://typo3blogger.de/tca-advanced-mm_match_fields-subquery-sorting/
答案 1 :(得分:0)
通过使用MM_match_fields为这两个字段工作TCA现在看起来像:
'related' => [
'label' => 'LLL:EXT:dreipc_myadlershof/Resources/Private/Language/locallang_db.xlf:tx_dreipcmyadlershof_domain_model_news.related',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_news_domain_model_news',
'foreign_table_where' => 'AND tx_news_domain_model_news.uid != ###THIS_UID### AND tx_news_domain_model_news.deleted = 0 AND tx_news_domain_model_news.hidden = 0 AND tx_news_domain_model_news.is_event = 0 AND tx_news_domain_model_news.enable = 1 AND tx_news_domain_model_news.sample = 0 ORDER BY tx_news_domain_model_news.datetime DESC',
'MM' => 'tx_news_domain_model_news_related_mm',
'MM_match_fields' => [
'fieldname' => 'related',
],
'size' => 20,
'minitems' => 0,
'maxitems' => 100,
'wizards' => [
'suggest' => [
'type' => 'suggest',
'default' => [
'searchWholePhrase' => true
]
],
],
]
],
'related_event' => [
'label' => 'LLL:EXT:dreipc_myadlershof/Resources/Private/Language/locallang_db.xlf:tx_dreipcmyadlershof_domain_model_news.related_event',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_news_domain_model_news',
'foreign_table_where' => 'AND tx_news_domain_model_news.uid != ###THIS_UID### AND tx_news_domain_model_news.deleted = 0 AND tx_news_domain_model_news.hidden = 0 AND tx_news_domain_model_news.is_event = 1 AND tx_news_domain_model_news.enable = 1 AND tx_news_domain_model_news.sample = 0 ORDER BY tx_news_domain_model_news.datetime DESC',
'MM' => 'tx_news_domain_model_news_related_mm',
'MM_match_fields' => [
'fieldname' => 'related_event',
],
'size' => 20,
'minitems' => 0,
'maxitems' => 100,
'wizards' => [
'suggest' => [
'type' => 'suggest',
'default' => [
'searchWholePhrase' => true,
'addWhere' => ' AND tx_news_domain_model_news.uid != ###THIS_UID### AND tx_news_domain_model_news.is_event = 1'
]
]
],
]
],
为此,我们还需要将字段 fieldname 添加到表 tx_news_domain_model_news_related_mm