Typo3 7 Extbase 操作 FlexForm

Typo3 7 Extbase Actions FlexForm

我使用的是 Typo3 7.6.10 Extbase Builder。 我创建了一个扩展,并且有一个带有一个控制器的模型。 在我的控制器中,我有 2 个动作。 list();searchbar();

现在我想在添加插件时在后端选择启动哪个操作!我无法执行此选项。 我听说了 FlexForm 选项和 switchableControllerActions

但我做不到。文档很糟糕 https://wiki.typo3.org/Extension_Development,_using_Flexforms#Create_Your_Extension

例如:t3lib_extMgm 已弃用

是否有有效的示例如何执行此操作?

创建一个 .xml 文件。我不知道有什么约定,但是将文件命名为与您的插件相同的名称是个好主意,因为您的扩展的每种插件类型都需要单独的文件。

typo3conf/ext/extensionkey/Configuration/FlexForms/Pluginname.xml

xml 文件需要至少包含一个 TCEform 结构,其中键 switchableControllerActions 作为 select 类型选项,就像这样。

<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
    <sheets>
        <general>
            <ROOT>
                <TCEforms>
                    <sheetTitle>Display type</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <switchableControllerActions>
                        <TCEforms>
                            <label>Display</label>
                            <config>
                                <type>select</type>
                                <items type="array">
                                    <numIndex index="1" type="array">
                                        <numIndex index="0">List</numIndex>
                                        <numIndex index="1">Controller->list</numIndex>
                                    </numIndex>
                                    <numIndex index="2" type="array">
                                        <numIndex index="0">Search bar</numIndex>
                                        <numIndex index="1">Controller->searchbar</numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </switchableControllerActions>
                </el>
            </ROOT>
        </general>
    </sheets>
</T3DataStructure>

接下来,通过注册文件使 Flexform 在后端已知。记下 $pluginSignature 变量。它必须匹配 extension_pluginname 的模式。您必须相应地定义插件名称。

// Register FlexForm Configuration
 $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['extension_plugin'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
    'extension_plugin', 
    'FILE:EXT:extensionkey/Configuration/FlexForms/Pluginname.xml'
);

在上面的示例中,相应地替换“extension_plugin”和“extensionkey”。

最后,刷新系统缓存,您应该可以开始了。配置选项应该出现在插件设置中。然后定义的 switchableControllerActions 值应该替换插件实例的标准操作。

但是,还有几点需要指出:请注意,您定义的操作替换了允许的 cacheableControllerAction 组合。因此,例如,如果您的扩展有针对此插件实例的另一个操作 show(),则需要像这样附加该操作:

<numIndex index="1" type="array">
    <numIndex index="0">List</numIndex>
    <numIndex index="1">Controller->list;Controller->show</numIndex>
</numIndex>