diff --git a/src/EventListener/Navigation/CalendarNavigationListener.php b/src/EventListener/Navigation/CalendarNavigationListener.php index 38a3669..c6ff5d5 100644 --- a/src/EventListener/Navigation/CalendarNavigationListener.php +++ b/src/EventListener/Navigation/CalendarNavigationListener.php @@ -20,7 +20,7 @@ class CalendarNavigationListener extends AbstractNavigationListener { protected function getUrlKey(): string { - return 'events'; + return isset($GLOBALS['TL_CONFIG']['useAutoItem']) ? 'events' : 'auto_item'; } protected function findCurrent(): ?CalendarEventsModel diff --git a/src/EventListener/Navigation/FaqNavigationListener.php b/src/EventListener/Navigation/FaqNavigationListener.php index 1a1f29b..f07dc9c 100644 --- a/src/EventListener/Navigation/FaqNavigationListener.php +++ b/src/EventListener/Navigation/FaqNavigationListener.php @@ -20,7 +20,7 @@ class FaqNavigationListener extends AbstractNavigationListener { protected function getUrlKey(): string { - return 'items'; + return isset($GLOBALS['TL_CONFIG']['useAutoItem']) ? 'items' : 'auto_item'; } protected function findCurrent(): ?FaqModel diff --git a/src/EventListener/Navigation/NewsNavigationListener.php b/src/EventListener/Navigation/NewsNavigationListener.php index 581458d..1dca119 100644 --- a/src/EventListener/Navigation/NewsNavigationListener.php +++ b/src/EventListener/Navigation/NewsNavigationListener.php @@ -20,7 +20,7 @@ class NewsNavigationListener extends AbstractNavigationListener { protected function getUrlKey(): string { - return 'items'; + return isset($GLOBALS['TL_CONFIG']['useAutoItem']) ? 'items' : 'auto_item'; } protected function findCurrent(): ?NewsModel diff --git a/src/Navigation/UrlParameterBag.php b/src/Navigation/UrlParameterBag.php index b8f8392..2d08b9e 100644 --- a/src/Navigation/UrlParameterBag.php +++ b/src/Navigation/UrlParameterBag.php @@ -105,17 +105,8 @@ public function generateParameters(): ?string return null; } - if (isset($attributes['auto_item'])) { - throw new \RuntimeException('Do not set auto_item parameter'); - } - - // 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'] ?? []))); + if ($GLOBALS['TL_CONFIG']['useAutoItem'] ?? true) { + $auto_item = array_intersect_key($attributes, array_flip(array_merge((array) ($GLOBALS['TL_AUTO_ITEM'] ?? []), ['auto_item']))); switch (\count($auto_item)) { case 0: