Reputation: 2249
I have my extension in TYPO3 4.x with Backened module (EXT:wec_map),
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule(
'tools','txwecmapM1',
'',
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('wec_map').'Classes/Module/MapAdministration/'
);
Now, I upgraded TYPO3 4.x to TYPO3 8.7.8. I'm having an issue with backend module its shows empty space in the tools menu group. I have replaced deprecated module registration method like this:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'txwecmapM1',
'tools', // Make module a submodule of 'web'
'txwecmapM1', // Submodule key
'', // Position
[
'access' => 'user,group',
'icon' => 'EXT:' . $extKey . '/Resources/Public/Icons/user_mod_bewebuser.svg',
'labels' => 'LLL:EXT:' . $extKey . '/Resources/Private/Languages/Module/MapAdministration/locallang_mod.xlf',
]
);
It's working nice but the icon shows default typo3 icon and label shows ":mlang_labels_tablabel". can anyone help me out in this?
second thing, while i click on module its shows:
"Could not analyse class: "Tx_TxwecmapM1_Controller_accessController" maybe not loaded or no autoloader? Class Tx_TxwecmapM1_Controller_accessController does not exist"
Please help me...
Upvotes: 0
Views: 582
Reputation: 1
A bit late to the party but still here is the way to do it (thx to typo3 slack).
Create a Controller in Classes/Controller which extends \TYPO3\CMS\Backend\Module\BaseScriptClass
and add the following functions:
function loadMCONF()
{
$this->MCONF = $GLOBALS['TBE_MODULES']['_configuration']['myext_mymoduleM1'];
}
function init()
{
$this->loadMCONF();
parent::init();
$this->getBackendUser()->modAccess($this->MCONF, 1);
$this->pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
}
public function mainAction(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response)
{
$this->postVars = $request->getParsedBody();
$this->init();
$this->main();
$response->getBody()->write($this->content . $this->doc->endPage());
return $response;
}`
that way you can recycle most of your old code from main() and init().
Use addModule to register the module:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule(
'myext',
'mymoduleM1',
'',
'',
[
'routeTarget' => \MyVendor\MyExt\Controller\BackendModuleController::class . '::mainAction',
'access' => 'admin',
'name' => 'myext_mymoduleM1',
'labels' => [
'tabs_images' => [
'tab' => 'EXT:myext/Resources/Public/Icons/BackendModule.svg',
],
'll_ref' => 'LLL:EXT:myext/Resources/Private/Language/locallang_mod.xml',
]
]
);
Upvotes: 0
Reputation: 1024
The module definition looks perfectly ok to me -
but AFAIK, it should read $_EXTKEY
instead of $extKey
.
Oh, and the second problem might be caused by not using the namespace here.
This should do it:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'Vendor.' . $_EXTKEY,
'tools', // Make module a submodule of 'web'
'txwecmapM1', // Submodule key
'', // Position
[
'access' => 'user,group',
'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/user_mod_bewebuser.svg',
'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Languages/Module/MapAdministration/locallang_mod.xlf',
]
);
Upvotes: 0