typo3 add a main menu in backend
Asked Answered
L

1

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

Largehearted answered 29/11, 2017 at 14:8 Comment(0)
S
0

A backed module is registered using the following in your ext_tables.php (or at least this is how I've been doing it).

\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',
    )
);

EDIT

Note that is sounds like $_EXTKEY may end up being removed in the future. Instead of using $_EXTKEY you can do:

'Vendor.ExtensionName', // Vendor dot Extension Name in CamelCase
Sublunary answered 30/11, 2017 at 14:25 Comment(3)
I tried this one. If I omit the submodule key I do my Icon and Label is applied to a both the main Module AND a submodule. If I add a submenu key my result is the same as in my original question. Why are there two half-way working functions doing the same thing? Is one of them legacy code for older Typo3 versions or something?Largehearted
It might be a good idea to change the vendor name here ('DEMO'). Vendor name is typically not all caps (Exception: TYPO3\CMS), see "Vendor names must start with an uppercase character and are usually written in UpperCamelCase style" docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Namespaces/…Pani
Also about $_EXTKEY: "Additionally, it is recommend to use the extension name (e.g. "tt_address") instead of $_EXTKEY within the two configuration files as this variable will be removed in the future: docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/…Pani

© 2022 - 2024 — McMap. All rights reserved.