2017-07-25 82 views
0

是否有可能使用TCA字段类型“选择”的表有数千个条目?TYPO3 TCA类型“选择”性能问题

不应该显示带有条目的选择框(否则记录会加载分钟,或者您会收到内存限制或最大执行时间错误),但是像搜索字段(如现有向导“建议”)或记录浏览器(如TCA类型“组”)。

回答

1

有可能与TCA型 “组” 和(很重要!)设置foreign_table:

'config' => [ 
    'type' => 'group', 
    'internal_type' => 'db', 
    'allowed' => 'fe_users', 
    'foreign_table' => 'fe_users' 
], 

从官方文档(https://docs.typo3.org/typo3cms/TCAReference/ColumnsConfig/Type/Group.html#foreign-table):

foreign_table: This property does not really exist for group-type fields. It is needed as a workaround for an Extbase limitation. It is used to resolve dependencies during Extbase persistence. It should hold the same values as property allowed. Notice that only one table name is allowed here in contrast to the property allowed itself.

0

寻找groupinternal_type设置为db作为替代select类型;这正是你在这里所需要的。这是允许您特定用例的唯一字段类型。

替代选项包括对字段使用input类型,并将其与向导拟合,然后配置该向导,以便它替换原始字段并仅显示向导。

不要忘记检查你列出的表的SQL键。如果您的列表使用未索引的列,则可以通过简单地为所用列添加SQL索引来将时间缩短到极限。

+0

我担心它必须是键入“select”或“inline”,因为Extbase存储库只能正确处理这些类型 - 对于“subrecord”的查询似乎只能用这些类型。例如:$ query-> equals('mySelectField.uid',123); – Sven

+0

听起来像别的东西,可能是你的领域模型注释,应该归咎于此。没有理由为什么Extbase存储库不应该像处理任何其他(有效的TCA)类型那样处理“组”类型字段。也许你没有声明'允许的'表列表? –

+0

请参阅'\ TYPO3 \ CMS \ Extbase \ Persistence \ Generic \ Mapper \ DataMapFactory :: setRelations'。如果您阅读并调用函数的主体,您可以知道哪种类型的TCA参数可以使用,哪种类型被认为是适当的关系。 –

0

我使用的是旧TCA字段中键入“组”,这也解决了TYPO3 CMS这种行为8

'my_select_field' => [ 
    'label' => 'My select field', 
    'config' => [ 
     'type' => 'group', 
     'internal_type' => 'db', 
     'allowed' => 'my_foreign_table_name', 
     'size' => 1, 
     'minitems' => 0, 
     'maxitems' => 1, 
     'suggestOptions' => [ 
      'default' => [ 
       'pidList' => 0, 
       'searchCondition' => 'hidden=0', 
       'searchWholePhrase' => 1 
      ] 
     ] 
    ] 
] 
+0

正如我的问题所述,我知道类型“组”。但不幸的是,这种字段类型是不可能的,因为组可以包含来自多个表的记录,因此很多Extbase操作是不可能的。 Extbase在许多方面不支持字段类型“group”,例如存储库中的数据库查询,如$ query-> equals('mySelectField.uid',123); – Sven

+0

这是一个不正确的断言。 'group'类型支持单个表格 - 但你可以用'allowed'设置来控制它,而不是'table'。 –

+0

是的,但即使您只在选项“允许”中命名一个表,但Extbase存储库中的查询无法处理与TCA类型为“group”的其他表的关系。 – Sven

0

一种选择是设置字段设置为“只读”。当然,然后在TYPO3 BE中不能编辑这个字段,但是如果数据来了,例如从外部来看,这是我可以忍受的一个缺点。

'config' => [ 
    'type' => 'select', 
    'foreign_table' => 'fe_users', 
    'size' => 1, 
    'minitems' => 1, 
    'maxitems' => 2, // it has to be > 1 because else a selectbox is rendered 
    'readOnly' => 1, // readOnly because of performance issues 
],