From 5a9b89c7befbbb509bfc0f8c7663c671e39bfcbd Mon Sep 17 00:00:00 2001 From: Leo Feyer <1192057+leofeyer@users.noreply.github.com> Date: Fri, 21 Apr 2023 09:57:24 +0200 Subject: [PATCH] Correctly handle auto items in Contao 4 and 5 (#228) --- src/Navigation/UrlParameterBag.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Navigation/UrlParameterBag.php b/src/Navigation/UrlParameterBag.php index bcefa80..b8f8392 100644 --- a/src/Navigation/UrlParameterBag.php +++ b/src/Navigation/UrlParameterBag.php @@ -109,7 +109,12 @@ public function generateParameters(): ?string throw new \RuntimeException('Do not set auto_item parameter'); } - if ($GLOBALS['TL_CONFIG']['useAutoItem'] ?? true) { + // Contao 5 always uses auto_item + if (!\array_key_exists('useAutoItem', $GLOBALS['TL_CONFIG'])) { + $key = key($attributes); + $auto_item = $attributes[$key]; + unset($attributes[$key]); + } elseif ($GLOBALS['TL_CONFIG']['useAutoItem']) { $auto_item = array_intersect_key($attributes, array_flip((array) ($GLOBALS['TL_AUTO_ITEM'] ?? []))); switch (\count($auto_item)) {