Reputation: 802
It seems that every "routePath" has to be unique within the same plugin, even for different actions, which is a design fault or bug in my eyes.
Example with EXT:news, which has plugin "Pi1" with actions "list" and "detail", using default setup (https://docs.typo3.org/p/georgringer/news/8.6/en-us/AdministratorManual/BestPractice/Routing/Index.html#basic-setup-including-categories-tags-and-the-rss-atom-feed). When having the same slug for a news record and a news category record (e.g. "hello-world") you are getting a problem, the route "news/list/hello-world" doesn't list the news of category "hello world" because "hello world" is recognized as news title (just because it's configured before the category in the site configuration).
What to do in this case? Using configuration option "limitToPages" (what is not ideal when having editors adding new plugins)? Splitting it up in different plugins (what is not possible for third party extensions)? Prefixing routePath, e.g. "category-*" (what also doesn't help when an editor creates a news with this slug)?
Upvotes: 0
Views: 383
Reputation: 1236
No, sorry to say that this is not a design fault, it is a configuration fault or an data conflict.
Neither a human nor a machine/program could determine if you now mean with a valid part of a url having two or multiple routes, which checks further data and both has has a valid value for it, thus both are matching and are "valid" routes.
But as there can only one route be executed, you could either implemend or say do the first, or the last of it, which is done (not sure which one currently).
So, your route configuration is not deterministic at all. You can shift the order of both routes to change which one will win if both are considiered valid and matched.
So you have following options to be more deterministic:
Maybe it would be better to ship that as example or in the documentation for the news extionsion. But as there a lot of different use cases and constellations, there could only be examples. They have to be correctly setup for that instance, and project needs. (This does apply to all plugins, not only ext:news
.)
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
- routePath: '/'
_controller: 'News::list'
- routePath: '/page-{page}'
_controller: 'News::list'
_arguments:
page: '@widget_0/currentPage'
# detail subroute prefixed
- routePath: '/detail/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
# list category subroute prefixed
- routePath: '/category/{category-name}'
_controller: 'News::list'
_arguments:
category-name: overwriteDemand/categories
# list tag subroute prefixed
- routePath: '/tag/{tag-name}'
_controller: 'News::list'
_arguments:
tag-name: overwriteDemand/tags
defaultController: 'News::list'
defaults:
page: '0'
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
page:
type: StaticRangeMapper
start: '1'
end: '100'
category-name:
type: PersistedAliasMapper
tableName: sys_category
routeFieldName: slug
tag-name:
type: PersistedAliasMapper
tableName: tx_news_domain_model_tag
routeFieldName: slug
PageTypeSuffix:
type: PageType
map:
'feed.xml': 9818
Upvotes: 3