You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TYPO3后端自定义标签页渲染实现方案咨询

TYPO3后端自定义标签页渲染实现方案咨询

我现在正在推进一个有点挑战性的任务:想要扩展 vendor/typo3/cms-backend/Classes/Form/Container/AbstractContainer.php 中的 renderTabMenu 方法,用自己的模板来渲染后端的标签页。

问题在于,这个模板是硬编码死的,官方并没有提供内置的解决方案(源码里的注释也提到了这个遗憾)。我已经尝试过用事件监听器,或者继承子类 TabsContainer 来实现,但目前都没找到可行的办法。

下面是负责模板渲染的原方法代码:

protected function renderTabMenu(array $menuItems, $domId, $defaultTabIndex = 1)
{
    // @todo: It's unfortunate we're using Typo3Fluid TemplateView directly here. We can't
    //        inject BackendViewFactory here since __construct() is polluted by NodeInterface.
    //        Remove __construct() from NodeInterface to have DI, then use BackendViewFactory here.
    $view = GeneralUtility::makeInstance(TemplateView::class);
    $templatePaths = $view->getRenderingContext()->getTemplatePaths();
    $templatePaths->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates')]);
    $templatePaths->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Partials')]);
    $view->assignMultiple([
        'id' => $domId,
        'items' => $menuItems,
        'defaultTabIndex' => $defaultTabIndex,
        'wrapContent' => false,
        'storeLastActiveTab' => true,
    ]);
    return $view->render('Form/Tabs');
}

我的目标是用我自己的模板来渲染后端标签页,这个模板位于 Resources/Private/Backend/Partials/ModuleTemplate/Tabs.html,有没有大佬知道该怎么实现这个需求呢?

备注:内容来源于stack exchange,提问作者Stackfactory

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 10:33:09