Hey Spooky,
da hatte ich wieder ein Brett vor dem Kopf. Danke für den Hinweis, absolut logisch. Damit klappt es wunderbar.
PHP-Code:
<?php
namespace App\EventListener;
use Contao\CoreBundle\ServiceAnnotation\Hook;
/**
* @Hook("replaceInsertTags")
*/
class ColorInsertTagListener
{
public const TAG = 'color';
public function __invoke(string $tag)
{
// Split tag
$chunks = explode('::', $tag, 3);
// Check if tag is valid
if (count($chunks) !== 3 || $chunks[0] !== self::TAG) return false;
// Return string
return '<span class="color-' . $chunks[1] . '">' . $chunks[2] . '</span>';
}
}
PHP-Code:
<?php
namespace App\EventListener;
use Contao\CoreBundle\ServiceAnnotation\Hook;
/**
* @Hook("replaceInsertTags")
*/
class StrongInsertTagListener
{
public const TAG = 'strong';
public function __invoke(string $tag)
{
// Split tag
$chunks = explode('::', $tag, 2);
// Check if tag is valid
if (count($chunks) !== 2 || $chunks[0] !== self::TAG) return false;
// Return string
return '<strong>' . $chunks[1] . '</strong>';
}
}
Lesezeichen