typo3 - 类别和标签的新闻 URL 问题
问题描述
以下是使新闻页面 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
...
推荐阅读
- python - 值是否包含在另一个numpy数组中的指示数组?
- mongodb - 解析服务器升级到 v4.2:无法确保用户电子邮件地址的唯一性
- c++ - 我无法在 VSCode 中调试我的 C++ 代码
- kubernetes - Kubernetes API:列出带有标签的 pod
- css - 尝试导入样式表时 VS Code 的行为很奇怪
- python - python manage.py runserver 不工作
- .net - 使用 .net core 每 15 秒更新一次页面内容的最佳方法
- c++ - 为什么我得到'{'和';' 使用 Visual Studio 2019 的此代码中的错误?
- r - 如何将列表中数据框中的列设置为因子?
- azure-devops - 尝试使用 Azure DevOps 进行 SqlAzureDacpacDeployment 时,找不到使用搜索模式部署的文件