3

I want to get rifd of the cHash get parameter when using routing enhancers with custom extension.

The TYPO3 docs/changelog assume that this is possible:

If you really have the requirement to never have a cHash argument, ensure that all placeholders are having strict definitions on what could be the result of the page segment ...

But what exactly does strict definitions mean.

This is my routing configuration:

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+'

the result is

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

I also have a routing for tx_news that works fine do not append a 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+'
PrakashG
  • 1,642
  • 5
  • 20
  • 30
g-ffm
  • 55
  • 1
  • 4
  • https://stackoverflow.com/a/53054351/923560 provides a workaround by using a mapper which returns the same value as provided from the route. It makes the cHash disappear. – Abdull Jun 27 '19 at 18:49

1 Answers1

2

My workaround was a StaticRangeMapper.

Hint: 1000 is currently the maximum in the TYPO3 core.

  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
Guido S
  • 106
  • 3
  • Thanks, this works. But, as you wrote, it is a workaound not a solution. – g-ffm Feb 14 '19 at 09:50
  • Its only applicable if you have numeric values from 1...1000. But maybe the magic is to jaust add a mapper to the configuration. But in some cases i can not use one of the standard mappers, maybe i have to write a custom mapper, just to get rid of the cHash parameter. – g-ffm Feb 14 '19 at 09:57
  • Of course, you're right. If you need an example for a custom aspect, look here: https://gist.github.com/wazum/e5862338fbc4466bac8c66bf11efdf9e – Guido S Feb 14 '19 at 10:27
  • When all Placeholders have an aspect configuration, then the chash disappears. I added a custom Mapper that does nothing, just for the case when i actually does not need one. – g-ffm Feb 15 '19 at 12:16