以下是我的代码,用于使新闻页面URL用户友好。详细信息页面URL可以很好地处理此问题,但它不适用于类别和标记。
News:
type: Extbase
limitToPages:
- 16
extension: News
plugin: Pi1
routes:
-
routePath: '/page/{page}'
_controller: 'News::list'
_arguments:
page: '@widget_0/currentPage'
-
routePath: '/{news_title}'
_controller: 'News::detail'
_arguments:
news_title: news
-
routePath: '/topic/{category_name}'
_controller: 'News::list'
_arguments:
category_name: overwriteDemand/categories
-
routePath: '/tag/{tag_name}'
_controller: 'News::list'
_arguments:
tag_name: 'overwriteDemand/tags'
defaultController: 'News::list'
defaults:
page: '0'
requirements:
news_title: '^[a-zA-Z0-9].*$'
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: path_segment
tag_name:
type: PersistedAliasMapper
tableName: tx_news_domain_model_tag
routeFieldName: slug
任何人,请帮我找出这是怎么回事?我已经评论了skipControllerAndAction = 1
Typo3版本-10.4.16,新闻-8.5.2
谢谢!
类别的routePath不符合您定义的要求(没有news_title
(。
文件显示:
如果为生成URL而提供的输入不符合要求,则路由增强器不会提供变体,并且参数将作为常规查询参数添加到URL中。
只需在它们所属的routePath中移动需求(用于详细信息视图的路径(。
更新:纠正YAML以澄清所需的更改
News:
...
routes:
-
...
-
routePath: '/{news_title}'
_controller: 'News::detail'
_arguments:
news_title: news
requirements:
news_title: '^[a-zA-Z0-9].*$'
defaultController: 'News::list'
defaults:
page: '1'
aspects:
news_title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
...