一个扩展中的多个控制器 [英] Multiple controllers in an extension
本文介绍了一个扩展中的多个控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里看到https://docs.typo3.org/typo3cms/extensions/news/FlexForms和switchableControllerActions可以使用多个控制器。问题是,当我将插件添加到站点时,我必须指定哪个控制器应该为该站点工作。我希望配置直接在扩展中进行,而不是从typo3后端。
我知道我可以使用页面ID并调用基于它的函数,但我正在努力避免它,并寻找更好的解决方案。
推荐答案
确保这是可能的。这里需要使用FlexForms,它基本上是TT_CONTENT记录中基于XML的字段。因此,您可以直接配置您的插件,您的内容记录。通常用于设置对记录、排序等的限制,但也用于设置任何允许的控制器->操作组合,其中第一个为默认值。只要看一看一些众所周知的扩展,他们是如何使用它的。 下面是Flexform的相关部分的一些抽象:
<switchableControllerActions>
<TCEforms>
<label>LLL:EXT:ra_registration/Resources/Private/Language/locallang_be.xml:flexforms_general.mode</label>
<config>
<type>select</type>
<items>
<numIndex index="0">
<numIndex index="0">LLL:EXT:ra_registration/Resources/Private/Language/locallang_be.xml:flexforms_general.mode.registration_index</numIndex>
<numIndex index="1">Registration->index;Registration->register;User->new;User->create;User->confirm;User->index;User->remind</numIndex>
</numIndex>
<numIndex index="1">
<numIndex index="0">LLL:EXT:ra_registration/Resources/Private/Language/locallang_be.xml:flexforms_general.mode.registration_reminder</numIndex>
<numIndex index="1">User->index;User->remind;User->remindConfirm</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
如前所述,您可以定义任何控制器/操作组合,例如
我的产品->索引
或
我的客户->列表
等等
要使用Flexform,您需要在ext_tables.php中注册它
$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
TYPO3CMSCoreUtilityExtensionManagementUtility::addPiFlexFormValue('myextenion_pi1', 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/setup.xml');
这篇关于一个扩展中的多个控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文