Typo3 键入3 9.5 LTS routeEnhancers,用于带有uid的新闻,以使路径唯一
您好,我在TYPO3 Slack频道上找到了一个人正在使用的内容。yaml的这个片段存在于/config/my websitename/config.yaml 问题 但我注意到,当我有多篇标题相同的文章时,没有唯一的URL 问题 如何将文章uid添加到路径中以使其唯一,或者这是一个好主意?我发现它在文档中被忽略了,但不知道如何让它工作以扩展我已经拥有的,或者是否有更好的例子,有人可以给我如何获取新闻的唯一URL 答案 答案Typo3 键入3 9.5 LTS routeEnhancers,用于带有uid的新闻,以使路径唯一,typo3,typo3-9.x,Typo3,Typo3 9.x,您好,我在TYPO3 Slack频道上找到了一个人正在使用的内容。yaml的这个片段存在于/config/my websitename/config.yaml 问题 但我注意到,当我有多篇标题相同的文章时,没有唯一的URL 问题 如何将文章uid添加到路径中以使其唯一,或者这是一个好主意?我发现它在文档中被忽略了,但不知道如何让它工作以扩展我已经拥有的,或者是否有更好的例子,有人可以给我如何获取新闻的唯一URL 答案 答案 当您创建一篇具有标题的新文章时,它已经存在于数据库中,那么URL路径段应
当您创建一篇具有标题的新文章时,它已经存在于数据库中,那么URL路径段应该已经在后端生成,并带有一个由数字附加的字符串。这是默认的TCA配置uniqueInSite。请参阅EXT:news/Configuration/TCA/Overrides/tx\u news\u domain\u model\u news.php当您创建一篇新文章时,其标题已经存在于数据库中,那么URL路径段应该已经在后端生成,并带有一个数字附加的字符串。这是默认的TCA配置uniqueInSite。请参阅EXT:news/Configuration/TCA/Overrides/tx\u news\u domain\u model\u news.php
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'
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}'