Typo3 7 Extbase 操作 FlexForm

标签 typo3 extbase typo3-7.6.x

我使用 Typo3 7.6.10 Extbase Builder。 我创建了一个扩展,并拥有一个带有一个 Controller 的模型。 在我的 Controller 中我有 2 个操作。 list(); searchbar();

现在我想在添加插件时在后端选择要启动的操作!我无法做到这个选项。 我听说过 FlexForm Options 和 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 作为选择类型选项,如下所示。

<?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>

关于Typo3 7 Extbase 操作 FlexForm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38859550/

相关文章:

html - TYPO3 横向边界在 "Grid Element"附近

typo3 - Fluidtypo3 Flux - 保存在表字段中

typo3 - Powermail 中的添加、重命名或删除布局选项

search - 为什么indexed_search仅在TYPO3 8/9中的子页面上不起作用?

TYPO3 流体 f :image without width/height attribute/f:uri. 图像问题

typo3 - &lt;![CDATA[ ... ]]> 在 TYPO3 v8 Fluid 中不起作用

javascript - 如何在自己的 Typo3 6.2 扩展中包含 .js 文件?

redis - 我可以在我的 DDEV 容器中使用 Redis 吗?

css - TYPO3 菜单链接的自定义 css 类

php - 打字3 7.6.10 : How to extend the felogin extension?