簡體   English   中英

如何在 Typo3 9 中配置 routeEnhancers?

[英]How to configure the routeEnhancers in Typo3 9?

我正在使用typo3 9,5 並且我正在嘗試從擴展生成路由。 一切正常,直到我發現只要 URL 多,路由的參數就會導致錯誤

例子:

testRoute:
type: Extbase
extension: testExtension
plugin: testMain
routes:
  - { routePath: '/test/info/{name}/{period}', _controller: 
    'content::info', _arguments: {'name': 'name','period': 'period'} }
defaultController: 'content::info'
aspects:
  # here we get the needed information for a nice URL for _arguments
  name:
    type: PersistedAliasMapper
    tableName: 'xx'
    routeFieldName: slug
  period:
    type: PersistedAliasMapper
    tableName: 'xx'
    routeFieldName: slug

該路線工作正常。 問題:如果我有任何頁面以句點作為名稱(testperiod)typo3 嘗試生成我定義的 testRoute

   Error
   Parameter "tx_testextension_info__period" for route "tx_testextension_info_0" must 
     match 
    "[^/]++" ("" given) to generate a corresponding URL.

即使 URL 是:/xxxxxxxxxxxxxxxperiod 也會拋出錯誤

如何限制擴展的路由。

您可以嘗試使用參數 limitToPages 限制路由對指定頁面的影響。 例子 :

  NewsList:
    type: Plugin
    limitToPages: [3]
    routePath: '/{@widget_0/currentPage}'
    namespace: 'tx_news_pi1'
    aspects:
      '@widget_0/currentPage':
        type: StaticRangeMapper
        start: '1'
        end: '1000'

在這個例子中,我的路線只會在第 3 頁上工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM