From 980a6d83dd1e7d6765660001f25bc3f23999b7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Mummert?= Date: Wed, 4 Mar 2026 17:39:48 +0100 Subject: [PATCH] Include twig root marker and pending pinnwand DCA/template fixes --- contao/dca/tl_module.php | 5 ++++ contao/dca/tl_pinnwand.php | 24 ++++++++++++++++---- contao/templates/.twig-root | 0 contao/templates/frontend/pinnwand.html.twig | 6 +++-- 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 contao/dca/tl_module.php create mode 100644 contao/templates/.twig-root diff --git a/contao/dca/tl_module.php b/contao/dca/tl_module.php new file mode 100644 index 0000000..93f53ec --- /dev/null +++ b/contao/dca/tl_module.php @@ -0,0 +1,5 @@ + true, 'flag' => 6, 'inputType' => 'text', - 'eval' => ['rgxp' => 'datim', 'datepicker' => true, 'mandatory' => true, 'default' => time(), 'tl_class' => 'w50 wizard'], + 'default' => time(), + 'eval' => ['rgxp' => 'datim', 'datepicker' => true, 'mandatory' => true, 'tl_class' => 'w50 wizard'], 'sql' => 'int(10) unsigned NOT NULL default 0', ], 'dateModified' => [ 'sorting' => true, 'flag' => 6, 'inputType' => 'text', - 'eval' => ['rgxp' => 'datim', 'readonly' => true, 'default' => time(), 'tl_class' => 'w50'], + 'default' => time(), + 'eval' => ['rgxp' => 'datim', 'readonly' => true, 'tl_class' => 'w50'], 'sql' => 'int(10) unsigned NOT NULL default 0', ], 'published' => [ @@ -145,14 +147,14 @@ $GLOBALS['TL_DCA']['tl_pinnwand']['fields']['ueberschrift']['save_callback'][] = $start = 2; $base = $baseHeadline; - if (preg_match('/^(.*)\s-\s(\d+)$/', $baseHeadline, $matches)) { + if (preg_match('/^(.*)\s\((\d+)\)$/', $baseHeadline, $matches)) { $base = trim($matches[1]); $start = (int) $matches[2] + 1; } $id = (int) ($dataContainer->id ?? 0); $number = max(2, $start); - $candidate = sprintf('%s - %d', $base, $number); + $candidate = sprintf('%s (%d)', $base, $number); do { $exists = Database::getInstance() @@ -164,6 +166,18 @@ $GLOBALS['TL_DCA']['tl_pinnwand']['fields']['ueberschrift']['save_callback'][] = } ++$number; - $candidate = sprintf('%s - %d', $base, $number); + $candidate = sprintf('%s (%d)', $base, $number); } while (true); }; + +$GLOBALS['TL_DCA']['tl_pinnwand']['fields']['dateAdded']['load_callback'][] = static function (mixed $value): int { + $timestamp = (int) $value; + + return $timestamp > 0 ? $timestamp : time(); +}; + +$GLOBALS['TL_DCA']['tl_pinnwand']['fields']['dateModified']['load_callback'][] = static function (mixed $value): int { + $timestamp = (int) $value; + + return $timestamp > 0 ? $timestamp : time(); +}; diff --git a/contao/templates/.twig-root b/contao/templates/.twig-root new file mode 100644 index 0000000..e69de29 diff --git a/contao/templates/frontend/pinnwand.html.twig b/contao/templates/frontend/pinnwand.html.twig index 620fd97..e99b165 100644 --- a/contao/templates/frontend/pinnwand.html.twig +++ b/contao/templates/frontend/pinnwand.html.twig @@ -1,3 +1,5 @@ +{% use '@Contao/component/_figure.html.twig' %} +
@@ -10,9 +12,9 @@ data-seed="{{ entry.id }}" aria-label="{{ entry.headline }}" > - {% if entry.imagePath %} + {% if entry.imageFigure %}
- + {% with {figure: entry.imageFigure} %}{{ block('figure_component') }}{% endwith %}
{% endif %}