【发布时间】:2019-10-14 20:31:46
【问题描述】:
我需要在我的网址中省略一个或多个参数。例如:
domain.tld/page/my-article/
domain.tld/page/cat/2/my-article
两个网址都显示相同的页面。
这适用于第一个变体:
myplugin:
limitToPages:
- 80
type: Plugin
routePath: '/{uid}'
namespace: tx_myext_pi1
requirements:
uid: '[0-9]{1,4}'
aspects:
uid:
type: PersistedAliasMapper
tableName: tx_myext_items
routeFieldName: slug
这是第二个:
myplugin:
limitToPages:
- 80
type: Plugin
routePath: '/cat/{cat}/{uid}'
namespace: tx_myext_pi1
requirements:
cat '[0-9]{1}'
uid: '[0-9]{1,4}'
aspects:
uid:
type: PersistedAliasMapper
tableName: tx_myext_items
routeFieldName: slug
cat:
type: StaticRangeMapper
start: '1'
end: '10'
但是我不能让它们都工作......是否有可能定义一个允许忽略 cat 参数的路由增强器?
谢谢!
【问题讨论】:
-
这不叫“两个网址重复内容”吗?无论如何,如果您有方面的可选变体(如 cat),则必须定义所有可能的变体。在您的情况下,两个 routeEnhancers 'myplugin-uid' & 'myplugin-uid-cat'... 但是如果没有设置参数,您会感到很困惑。更好地改变您的概念,使用独特、简短和清晰的网址。