我使用项目表构建扩展,这些扩展可以是项目或对象,项目是多个对象的容器。
为了区分,使用复选框将项目标记为项目,勾选此复选框时,将显示可选字段。
该字段是项目与其包含的对象(相同表)之间的关系(m:n)。多个并排选择仅显示尚未通过foreign_table_where
分配给项目的非项目和对象。
此字段具有以下TCA:
'objects' => [
'displayCond' => 'FIELD:isproject:=:1',
'exclude' => 0,
'label' => $ll . 'tx_myext_domain_model_item.objects',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_myext_domain_model_item',
'foreign_table_where' => 'AND isproject = 0 AND tx_myext_domain_model_item.uid NOT IN (SELECT uid_foreign FROM tx_myext_item_object_mm WHERE uid_local != ###THIS_UID###)',
'MM' => 'tx_myext_item_object_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0
],
],
使用我的插件我提供选项(通过flexform)来选择仅显示对象,仅显示项目或两者,使用存储库中的以下代码完成:
public function findList($entryInclude = 'objects_only') {
/** @var \TYPO3\CMS\Extbase\Persistence\Generic\Query $query */
$query = $this->createQuery();
switch ($entryInclude) {
case 'projects_objects':
$foreign_uids = $this->createQuery()
->statement('SELECT uid_foreign FROM tx_myext_item_object_mm')
->execute();
$constraints = [
$query->equals('isproject', 1),
$query->logicalNot($query->in('uid', $foreign_uids))
];
break;
case 'projects_only':
$constraints = $query->equals('isproject', 1);
break;
default:
$constraints = $query->equals('isproject', 0);
break;
}
$query->matching($query->logicalAnd($constraints));
return $query->execute();
}
构建uid_foreign
表中找到的所有tx_myext_item_object_mm
数组的工作会导致错误......
答案 0 :(得分:0)
在我看来,这是一个自定义查询的案例。以下内容应该为您提供mm-table中未引用的对象:
{{1}}