Since TYPO3 Version 9.5 RouteEnhancers can be used to translate parameters of extensions to nice and human-readable URL-paths. Those usually contain a "static keyword (previously known to some as "postVarSets" keyword for some TYPO3 folks)" and a dynamic part based on f.e. path_segment field of the extension-record, like this:
routeEnhancers:
MyExtDetail:
type: Plugin
namespace: tx_myext_pi1
routePath: '/myext-detail/{uid}'
aspects:
uid:
type: PersistedAliasMapper
tableName: tx_myext_item
routeFieldName: path_segment
My Question is: Is a unique static part like "/myext-detail" here absolutely mandatory (as I believe it was with RealUrl) or is it entirely optional, or on what does this depend? Can I simply leave it out, or will I run into trouble, at least under certain conditions, or are there advantages I would miss?
I tried leaving it out in a simple case, and it did seem to work, but I'm unsure about more complex scenarios.
You may come in trouble.
But it is not necessary if you have a clean configuration.
Assuming you have two different plugins which show records in a list with pagination and as single (detail):
if these plugins reside on different pages you could configure single/detail display with just the record number (depending on the page you select the record from another table.)
even the page of the pagination could be configured without additional path segment: just add a prefix like page-
to the page number.
and although the paginations are based on different URL parameters (like tx_plugin1[page]
and tx_plugin2[page]
) the resulting URL may look the same as the configuration would be page dependent.
example:
Record1Plugin:
type: Extbase
limitToPages:
- 123
extension: MyExt
plugin: Record1Plugin
routes:
-
routePath: '/page-{page}'
_controller: 'Record1::list'
_arguments:
page: showPage
-
routePath: '/{record1Id}'
_controller: 'Record1::show'
_arguments:
record1id: record1
defaultController: 'Record1::list'
defaults:
page: '0'
requirements:
page: \d+
Record2Plugin:
type: Extbase
limitToPages:
- 456
extension: MyExt
plugin: Record2Plugin
routes:
-
routePath: '/page-{page}'
_controller: 'Record1::list'
_arguments:
page: showPage
-
routePath: '/{record2Id}'
_controller: 'Record2::show'
_arguments:
record2Id: record2
defaultController: 'Record2::list'
defaults:
page: '0'
requirements:
page: \d+