Paths from a custom TYPO3 extensions look like this:
And I want them to look like: https://example.com/events/detail/event-title/test-event/
routeEnhancer configuration looks like this:
routeEnhancers:
EventDetail:
type: Plugin
routePath: '/event-title/{event}'
namespace: tx_eventmanager_eventdisplay
defaults:
controller: 'Event'
aspects:
event:
type: PersistedAliasMapper
tableName: tx_eventmanager_domain_model_event
routeFieldName: path_segment
TYPO3 version is 11.5.34
The exact same configuration produces the desired result in another extension (in another Site) from which the current one was forked years ago. It worked even without "defaults", which I added because it looked like they might help. I tried it with type: Extbase instead but that didn't work with either extension for some reason.
So there seems to be some small but crucial difference between both extensions (or environments), but both have diverged considerably - what should I look out for? Or can I fix it by some additional configuration in routeEnhancer?
I already tried narrowing it down with ChatGPT, but that didn't help much. I tried different routeEnhancer configurations that it offered, which didn't improve it. And based on its advice I compared:
All of which were identical in both extensions. Other than that its advice is very broad.
As Julian Hofmann suggested, controller needs to be added as a static mapping. This feels hacky but gives the desired outcome:
EventDetail:
type: Plugin
dynamicPages:
withPlugin: eventmanager_eventdisplay
routePath: '/event-{controller}/{event}'
namespace: tx_eventmanager_eventdisplay
aspects:
event:
type: PersistedAliasMapper
tableName: tx_eventmanager_domain_model_event
routeFieldName: path_segment
controller:
type: StaticValueMapper
map:
title: Event