Separate the W&K names in the category list

The newline-separated names were rendered as one run-on string.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jürgen MummertandClaude Fable 5.1 committed 2026-09-26 16:59:33 +02:00
1 parent 6e75ad31ea
commit fb2bfa1ee8
2 files changed
+31 -1

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ $GLOBALS['TL_DCA']['tl_wk_category'] = [
'panelLayout' => 'search,limit',
],
'label' => [
'fields' => ['sorting', 'title', 'kind', 'wkNames'],
'fields' => ['title', 'kind', 'wkNames'],
'showColumns' => true,
],
'operations' => [
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Mummert\ContaoWkSyncBundle\EventListener\DataContainer;
use Contao\CoreBundle\DependencyInjection\Attribute\AsCallback;
use Contao\DataContainer;
use Contao\StringUtil;
/**
* Kategorienliste: die W&K-Bezeichnungen (eine pro Zeile) lesbar getrennt anzeigen.
*/
#[AsCallback(table: 'tl_wk_category', target: 'list.label.label')]
class CategoryLabelListener
{
/**
* @param list<string> $args Spaltenwerte in der Reihenfolge von list.label.fields
*
* @return list<string>
*/
public function __invoke(array $row, string $label, DataContainer $dc, array $args): array
{
$names = array_filter(array_map(trim(...), explode("\n", str_replace("\r", '', (string) ($row['wkNames'] ?? '')))));
$args[2] = implode('<span class="tl_gray"> · </span>', array_map(StringUtil::specialchars(...), $names));
return $args;
}
}