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:
- field "path_segment" in DB and indexes,
- 'path_segment' in TCA
- "configurePlugin" block in ext_localconf.php
All of which were identical in both extensions. Other than that its advice is very broad.
It seems, that you are talking about a
Extbase Pluginand want to replace the extbase request get arguments with a speaking url.Using the site configuraiton to define a routing is a good start, and the right place to do so. However, you are using the "wrong" route enhancer. The culprit is, that TYPO3 knowns two types of plugins - AbstractPlugins (Pi42 based/legacy) and
Extbase Plugins- and you need the correct route enhancer for each plugin type.The documentation explains the Extbase Plugin Route-Enhancer [1] and you may want to read it up for further explanation, special for the aspect part and posibilities.
A rough start should work using following route configuration:
Note: Always use a pre-fix for the route path and avoid recuring/same prefix for multiple plugins - or use limitToPage which helps as long as not two plugings with same prefix are on the same page. And you should use routePath prefix which are unlikely to be the slug of children page if tree lige slug paths are used (default).
It's not really recommended to use the Plugin routeenhanver for a extbase plugin as it takes care of Extbase specific requirements.
Other options
If it is really not a extbase plugin, and you want to use the type
Pluginenhancer than there are other culprits. First, that type does not support aspects argument mapping.So maybe following works for you:
The namespace (full plugin name) and the should be not a duplicate of the other plugin and unique - and matching the extension/plugin named used for registration. See [2] for description if this type.