首页 > 解决方案 > 如何为高级功能注册模块

问题描述

当我在typo3 cms 9.5.4 后端的菜单中选择Web/Functions 时,出现以下错误:

高级功能

未注册任何模块。请联系您的系统管理员。

系统管理员。我在任何地方都找不到如何注册模块。如何注册任何模块?

标签: typo3typo3-9.xfunction-module

解决方案


就像 Peter 写的那样,Extension func 已从核心中删除,实际上并未标记为与 9.5 版兼容。并应避免使用更多。

但是遵循两个文件将帮助您注册自己的模块:

分机/扩展/ext_tables.php

// Module wizard
if (TYPO3_MODE === 'BE') {
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
        'web_func',
        \Vendor\Extension\MyModuleFunction::class,
        null,
        'LLL:EXT:extension/Resources/Private/Language/locallang_module.xlf:mymodulefunction'
    );
}

ext/extension/Classes/MyModuleFunction.php

<?php
namespace Vendor\Extension;

class MyModuleFunction
{

    /**
     * Initialize the object
     *
     * @param \object $pObj A reference to the parent (calling) object
     * @throws \RuntimeException
     */
    public function init($pObj)
    {
        // Required method
    }

    /**
     * Checking for first level external objects
     */
    public function checkExtObj()
    {
        // Required method
    }

    /**
     * Main function creating the content for the module.
     *
     * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj
     */
    public function main()
    {
        return '<h1>My module function</h1>';
    }
}

推荐阅读