TYPO3:扩展到 运行 PHP 代码

TYPO3: Extension to run PHP code

这更像是一个基本问题:

如何在不添加领域模型和操作的情况下(通过 Extension Builder)获得 运行 简单 PHP 代码的扩展?

一般来说,有3种选择:

  • 创建一个在此处回答的内容元素:
  • 创建一个来自 "old" 类型的插件,以前称为 "pi_base"。
  • 基于extbase创建插件

我仍然会选择选项 3,因此您仍然需要采取行动。有动作很好,因为你添加了第二个变体,你可以只使用第二个动作,你不需要太多额外的代码。

拥有这样的扩展相当容易。我最近做的一个例子是这个扩展:https://github.com/sup7even/mailchimp

一般你需要:

ext_localconf.php

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Sup7even.' . $_EXTKEY,
    'Registration',
    array(
        'Form' => 'index,response,ajaxResponse'
    ),
    array(
        'Form' => 'index,response,ajaxResponse'
    )
);

ext_tables.php

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    'Sup7.' . $_EXTKEY,
    'Registration',
    'Mailchimp'
);

RegistrationController。默认情况下,将调用第一个操作,在本例中为 index,因此您需要 indexAction 并且模板必须为 Templates/Registration/Index.html.