Danke für den Versuch, aber das bringt mich leider nicht weiter. Ich will ja das mit einem Controller machen, so wie in der Contaodoku.
Ich habe jetzt Folgenden Struktur versucht:
app/ContaoManagerPlugin.php
PHP-Code:
<?php
use Contao\ManagerPlugin\Routing\RoutingPluginInterface;
use Symfony\Component\Config\Loader\LoaderResolverInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Contao\CoreBundle\ContaoCoreBundle;
use Contao\ManagerPlugin\Bundle\BundlePluginInterface;
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
class ContaoManagerPlugin implements BundlePluginInterface
{
/**
* {@inheritdoc}
*/
public function getBundles(ParserInterface $parser)
{
return [
BundleConfig::create(TextFmBundle\TextFmBundle::class)->setLoadAfter([ContaoCoreBundle::class])
];
}
}
composer.json
PHP-Code:
{
"type": "project",
"require": {
"codefog/contao-social_images": "^3.7",
"contao-themes-net/zero-one-theme-bundle": "^1.8",
"contao/calendar-bundle": "4.9.*",
"contao/comments-bundle": "4.9.*",
"contao/conflicts": "*@dev",
"contao/faq-bundle": "4.9.*",
"contao/listing-bundle": "4.9.*",
"contao/manager-bundle": "4.9.*",
"contao/news-bundle": "4.9.*",
"contao/newsletter-bundle": "4.9.*",
"heimseiten/contao-sticky-footer-backend-bundle": "^1.0",
"madeyourday/contao-rocksolid-antispam": "^2.0",
"numero2/contao-marketing-suite": "^1.0"
},
"extra": {
"contao-component-dir": "assets"
},
"scripts": {
"post-install-cmd": [
"Contao\\ManagerBundle\\Composer\\ScriptHandler::initializeApplication"
],
"post-update-cmd": [
"Contao\\ManagerBundle\\Composer\\ScriptHandler::initializeApplication"
]
},
"autoload": {
"psr-4": { "TextFmBundle\\": "src/TextFmBundle/" },
"classmap": ["app/ContaoManagerPlugin.php"]
}
}
TextFmBundle/Controller/ContentElement/TextFmController.php
PHP-Code:
<?php
namespace TextFmBundle\Controller\ContentElement;
use Contao\ContentModel;
use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController;
use Contao\CoreBundle\ServiceAnnotation\ContentElement;
use Contao\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* @ContentElement("text_fm",
* category="texts",
* )
*/
class TextFmController extends AbstractContentElementController
{
protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response
{
$template->text = $model->text;
return $template->getResponse();
}
}
TextFmBundle/TextFmBundle.php
PHP-Code:
<?php
namespace TextFmBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class TextFmBundle extends Bundle
{
}
TextFmBundle/Resources/config/routing.yml
PHP-Code:
app:
resource: "@TextFmBundle/Controller"
type: annotation
TextFmBundle/Resources/config/services.yml
PHP-Code:
services:
@TextFmBundle\Controller\ContentElement\TextFmController:
tags:
-
name: contao.content_element
category: texts
template: ce_text_fm
TextFmBundle/Resources/contao/dca/tl_content.php
PHP-Code:
<?php
$GLOBALS['TL_DCA']['tl_content']['palettes']['text_fm'] = '
{type_legend},type;
{text_legend},text;
{image_legend},addImage;
{protected_legend:hide},protected;
{invisible_legend:hide},invisible,start,stop;'
;
...das composer update im Contao-Manager läuft so mal durch, aber im Backend erscheint das Ding nicht in der Auswahl bei "Elementtyp"
Lesezeichen