Hallo Gemeinde,
nach neuerlichem Umstieg auf das wirklich gute Contao, will ich nun auch in die Entwicklung eigener Module einsteigen. Installiert habe ich V 5.3. Ich habe mich dazu der offiziellen Anleitung (https://docs.contao.org/dev/framewor...t-end-modules/) bedient. Dennoch wird es im Dropdown "Modultyp" der Fronten Module im Backend nicht angezeigt. Die dazu erstellten Dateien sehen so aus:
src/Controller/FrontendModule/ExampleModuleController.php
PHP-Code:
<?php
namespace App\Controller\FrontendModule;
use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController;
use Contao\CoreBundle\DependencyInjection\Attribute\AsFrontendModule;
use Contao\ModuleModel;
use Contao\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
#[AsFrontendModule(category: 'miscellaneous')]
class ExampleModuleController extends AbstractFrontendModuleController
{
protected function getResponse(Template $template, ModuleModel $model, Request $request): Response
{
$template->action = "TEST !!";
return $template->getResponse();
}
}
contao/dca/tl_module.php
PHP-Code:
<?php
$GLOBALS['TL_DCA']['tl_module']['palettes']['my_frontend_module'] =
'{title_legend},name,type;{redirect_legend},jumpTo'
;
templates/mod_my_frontend_module.html5
HTML-Code:
<div class="my-frontend-module">
<p>
<?= $this->action ?>
</p>
</div>
contao/languages/en/modules.php
PHP-Code:
<?php
$GLOBALS['TL_LANG']['FMD']['my_frontend_module'] = [
'My front end module',
'A front end module for testing purposes.',
];
In der Console habe ich diese Infos abrufen können, also registriert scheint es zu sein:
Code:
vendor/bin/contao-console debug:container App\Controller\FrontendModule\ExampleModuleController
Code:
Information for Service "App\Controller\FrontendModule\ExampleModuleController"
===============================================================================
---------------- -------------------------------------------------------
Option Value
---------------- -------------------------------------------------------
Service ID App\Controller\FrontendModule\ExampleModuleController
Class App\Controller\FrontendModule\ExampleModuleController
Tags controller.service_arguments
container.service_subscriber
Calls setContainer
Public yes
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired yes
Autoconfigured yes
Usages none
---------------- -------------------------------------------------------
Vielen Dank für Eure Hilfe
Sven