How to get Speaking URLs for News 7.0.7 on Typo3 9.5.0
You can do this with the routeEnhancers
directive in your site configuration YAML file (typically htdocs/config/sites//config.yaml). There is an example in the official documentation, though hidden a little bit:
https://docs.typo3.org/typo3cms/extensions/core/Changelog/9.5/Feature-86365-RoutingEnhancersAndAspects.html
This is a configuration I am actively using:
rootPageId: <site id>
...
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages:
- 49 (when your news detail page id is 49)
- ...
extension: News
plugin: Pi1
routes:
-
routePath: '/blog/{page}'
_controller: 'News::list'
_arguments:
page: '@widget_0/currentPage'
-
routePath: '/tag/{tag_name}'
_controller: 'News::list'
_arguments:
tag_name: overwriteDemand/tags
-
routePath: '/{news_title}'
_controller: 'News::detail'
_arguments:
news_title: news
-
routePath: '/archive/{year}/{month}'
_controller: 'News::archive'
defaultController: 'News::list'
defaults:
page: '0'
aspects:
news_title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
Working example typo3 9.5.5 with tx_news 7.1.0 with PersistedPatternMapper:
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages: [20,23,29,30]
extension: News
plugin: Pi1
routes:
- { routePath: '{page}',_controller: 'News::list',_arguments: {'page': '@widget_0/currentPage'} }
- { routePath: '{news_title}',_controller: 'News::detail',_arguments: {'news_title': 'news'} }
defaultController: 'News::list'
defaults:
page: '0'
requirements:
page: '\d+'
aspects:
news_title:
type: PersistedPatternMapper
tableName: 'tx_news_domain_model_news'
routeFieldPattern: '^(?P<path_segment>.+)-(?P<uid>\d+)$'
routeFieldResult: '{path_segment}-{uid}'
page:
type: StaticRangeMapper
start: '1'
end: '200'