我有两个不同的 FE 插件A
,并且B
(可以说)在它们各自的configuration/tca/
文件夹中带有 TCA 表单。
对于插件“A”,TCA 形式是A_TCA.php
“B”,它是“B_TCA.php”。这两种形式有许多共同的输入字段。(如标题、名称、描述和类别)
有没有一种方法可以定义_partial.php
可以被渲染A_TCA.php
和B_TCA.php
重用的东西?
如果这样的事情是可能的,那就太棒了
我正在使用 TYPO3 V 6.1 和扩展生成器
为什么不?TCA 配置只不过是 PHP 数组,因此您可以include_once()
将部分文件与“主”TCA 结合起来,始终尝试确保变量的名称在整个系统中是唯一的,尤其是当您想要制作许多部分时(即:)$TxMyextTCApartForAandB
:
_partial.php
<?php
$TxMyextCommonPartial = array(
'interface'=> array(
'showRecordFieldList' => 'name, url',
),
'types' => array(
'1' => array('showitem' => 'name, url'),
),
'columns' => array(
'name' => array(
'exclude' => 0,
'label' => 'Name of item',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim'
),
),
'url' => array(
'exclude' => 0,
'label' => 'URL of item',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim'
),
),
),
);
A_TCA.php:
<?php
if (!defined ('TYPO3_MODE')) {
die ('Access denied.');
}
include_once('_partial.php');
$TCA['tx_myext_domain_model_atable'] = array(
'ctrl' => $TCA['tx_myext_domain_model_atable']['ctrl'],
'interface' => array(
'showRecordFieldList' => $TxMyextCommonPartial['interface']['showRecordFieldList'].', additional_field_only_in_a_tca',
),
'types' => array(
'1' => $TxMyextCommonPartial['types']['1']['showitem'].', additional_field_only_in_a_tca',
),
'palettes' => array(
'1' => array('showitem' => ''),
),
'columns' => array(
'name' => $TxMyextCommonPartial['columns']['name'],
'url' => $TxMyextCommonPartial['columns']['url'],
'additional_field_only_in_a_tca' => array(
'exclude' => 0,
'label' => 'Additional field in A only',
'config' => array(
'type' => 'input',
'size' => 4,
'eval' => 'int'
),
),
),
);
甚至...
include_once('_partial.php');
$TCA['tx_myext_domain_model_atable'] = array(
'ctrl' => $TCA['tx_myext_domain_model_atable']['ctrl'],
'interface' => $TxMyextCommonPartial['interface'],
'types' => $TxMyextCommonPartial['types'],
'palettes' => $TxMyextCommonPartial['palettes'],
'columns' => $TxMyextCommonPartial['columns'],
);