![](/img/trans.png)
[英]TYPO3 9.5 LTS - configuration for custom PAGE type with routeEnhancers
[英]TYPO3 9.5 LTS routeEnhancers for news with uid to make path unique
您好,我在一个 TYPO3 Slack 频道上发现了一个人正在使用的内容。 这个yaml
存在于/config/my-websitename/config.yaml
...
routeEnhancers:
NewsList:
type: Extbase
limitToPages: [2,20,21,22,92]
extension: News
plugin: Pi1
routes:
- routePath: '/p{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+'
news_title: '^[a-zA-Z0-9].*$'
aspects:
page:
type: StaticRangeMapper
start: '1'
end: '100'
news_title:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'path_segment'
但我注意到,当我有多篇文章标题相同时,没有唯一的 URL。
如何将文章uid
添加到路径以使其独一无二或者这是一个好主意? 我发现文档中没有提到它,但不知道如何让它工作以扩展我已有的内容,或者是否有更好的示例可以告诉我如何获取新闻的唯一 url?
routeEnhancers:
NewsPlugin:
type: Extbase
extension: 'News'
plugin: 'Pi1'
routes:
- { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
defaultController: 'News::list'
aspects:
news_title:
type: PersistedPatternMapper
tableName: 'tx_news_domain_model_news'
routeFieldPattern: '^(?P<path_segment>.+)-(?P<uid>\d+)$'
routeFieldResult: '{path_segment}-{uid}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.