问题
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.
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
回答1:
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(
'DEMO.' . $_EXTKEY,
'web', // Make module a submodule of 'web'
'm2', // Submodule key
'', // Position
array(
'Demo' => 'list, new, delete, edit',
),
array(
'access' => 'user,group',
'icon' => 'EXT:' . $_EXTKEY . '/ext_icon.gif',
'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_m2.xlf',
)
);
来源:https://stackoverflow.com/questions/47554730/typo3-add-a-main-menu-in-backend