我有两个不同的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和扩展构建器
答案 0 :(得分:1)
为什么不呢? TCA配置只不过是PHP数组,所以你可以include_once()
你的部分文件,只需将它与'main'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'],
);