1

I am trying to add a new main module entry to the module navigation on the left of the backend of typo3. I have found online that this should be possibel through the ::addModule method. I am trying it like this:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule(
    'test',
    'sub',
    '',
    '',
    [
       'labels' => 'LLL:EXT:eh_bootstrap/Resources/Private/Language/locallang_mod_testxy.xlf',
        'name' => 'test',
        'iconIdentifier' => 'eh-bootstrap-icon',
        'access' => 'user,group'
    ]
);

having read the ExtensionManagementUtility-class the method should add a new main module when none with that particular name is known.

Now: If I leave the $sub parameter empty, it should add a blank main module to the menu. If I do that however, nothing is shown. With the $sub parameter a new main module is added along with its submodule.

However, the main module has no label and the label and icon that I intended for the main module is now labelling the sub module.

Typo3 Main Module has no label

Here is the lang-file:

<?xml version="1.0" encoding="UTF-8"?>
    <xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
        <file t3:id="1415816898" source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:34Z" product-name="lang">
        <header/>
            <body>
                <trans-unit id="mlang_labels_tablabel">
                    <source>Testxy stuff</source>
                </trans-unit>
                <trans-unit id="mlang_tabs_tab">
                    <source>Testxy</source>
                </trans-unit>
            </body>
        </file>
     </xliff>

The closing header-tag put me off a bit, but other xlf-files in typo3 have that too, so I guess it has a purpose. I copied this mostly from the lang-file for the web-module.

It find it quite hard to find good development guides for Typo3 and none have helped me out so far with this problem. Any clue what I could be missing here is appreciated.

Adding:

I now also tried the

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
    'EHAERER.' . $_EXTKEY,
    'test',
    'ehbootstrap',
    '',
    [],
    [
       'labels' => 'LLL:EXT:eh_bootstrap/Resources/Private/Language/locallang_mod_testxy.xlf',
        'name' => 'test',
        'iconIdentifier' => 'eh-bootstrap-icon',
        'access' => 'user,group'
    ]
);

method, which as it is currently adds the submodule to a blankly labelled main Module. If I omit the submodule key, my Icon and label get applied to a both the Main Module and a blank Submodule

4

1 回答 1

1

在您的 ext_tables.php 中使用以下内容注册了一个支持的模块(或者至少这是我一直在做的)。

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
    'Vendor.' . $_EXTKEY,
    'web', // Make module a submodule of either 'web', 'tools', 'admin tools', 'file', 'help', 'system', 'user'
    'm2', // Submodule key
    'bottom', // Position: top, bottom, before:<submodulekey>, after:<submodulekey>
    array(
        'Controller' => 'list, new, delete, edit',
    ),
    array(
        'access' => 'user,group',
        'icon'   => 'EXT:' . $_EXTKEY . '/ext_icon.gif',
        'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_m2.xlf',
    )
);

编辑

请注意,这听起来像 $_EXTKEY 将来可能最终会被删除。而不是使用 $_EXTKEY 你可以这样做:

'Vendor.ExtensionName', // Vendor dot Extension Name in CamelCase
于 2017-11-30T14:25:00.607 回答