如何使用路由增强器摆脱cHash?

时间:2019-02-13 15:28:50

标签: routing typo3 typo3-9.x

在使用具有自定义扩展名的路由增强器时,我想了解cHash get参数的问题。

TYPO3 docs / changelog认为这是可能的:

  

如果您确实需要绝对不要使用cHash参数,   确保所有占位符对什么有严格的定义   可能是网页细分的结果...

但是严格定义到底是什么意思。

这是我的路由配置:

routeEnhancers:
  ExecutiveSearchResultList:
    type: Extbase
    extension: executivesearch
    plugin: searchresultlist
    routes:
        - { routePath: '/list/{page}', _controller: 'Search::searchResultList', _arguments: {'page': 'page'} }
    defaultController: 'Search::searchResultList'
    defaults:
      page: '1'
      action: 'searchResultList'
      controller: 'Search'
    requirements:
      page: '\d+'

结果是

/path/to/my-page/list/1?cHash=6cd242916809d29b799debe824b37fcd

我也有一个tx_news的路由,可以正常工作,不要添加cHash:

NewsPlugin:
    type: Extbase
    extension: news
    plugin: Pi1
    routes:
      - { routePath: '/list/{page}', _controller: 'News::list', _arguments: {'page': '@widget_0/currentPage'} }
      - { routePath: '/tag/{tag_name}', _controller: 'News::list', _arguments: {'tag_name': 'overwriteDemand/tags'}}
      - { routePath: '/news/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
      - { routePath: '/archive/{year}/{month}', _controller: 'News::archive' }
    defaultController: 'News::list'
    aspects:
      news_title:
        type: PersistedAliasMapper
        tableName: 'tx_news_domain_model_news'
        routeFieldName: 'path_segment'
    defaults:
      page: '0'
    requirements:
      page: '\d+'

1 个答案:

答案 0 :(得分:0)

我的解决方法是使用StaticRangeMapper。

提示:TYPO3内核中当前最大为1000。

  NewsPlugin:
    type: Extbase
    limitToPages:
      - 56
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/list/{page}'
        _controller: 'News::list'
        _arguments:
          page: '@widget_0/currentPage'
      - routePath: '/detail/{news_title}'
        _controller: 'News::detail'
        _arguments:
          news_title: news
    defaultController: 'News::list'
    defaults:
      page: '0'
    requirements:
      page: \d+
    aspects:
      page:
        type: StaticRangeMapper
        start: '1'
        end: '1000'
      news_title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment