TYPO3新闻路由工作,但仍然可见哈希和其他URL部分



TYPO3 9.5中的路由和tx_news有问题。我已经尝试了所有的官方例子,但问题仍然存在,我不知道为什么。

我想拥有类似的URL

...home/news/detail/project-lounge-movetia-2

但我得到了:

...home/news/detail/project-lounge-movetia-2?tx_news_pi1[day]=11&tx_news_pi1[month]=12&tx_news_pi1[year]=2019&cHash=8fd7057d32ae3e3810b76f0bf4a06e39

配置是标准的:

routeEnhancers:
  News:
    type: Extbase
    limitToPages:
      - 40
      - 54
      - 55
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/'
        _controller: 'News::list'
      - routePath: '/page-{page}'
        _controller: 'News::list'
        _arguments:
          page: '@widget_0/currentPage'
      - routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      - routePath: '/{category-name}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
      - routePath: '/{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
    defaultController: 'News::list'
    defaults:
      page: '40'
    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: slug
      tag-name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug
    requirements:
      page: 'd+'

新闻标题变对了";"增强";,但其余的仍然存在(hash、id等(我不知道为什么会发生这种情况。我读了很多次关于路由的手册,但我不明白

如他们的文档所示,它应该包含更多

routeEnhancers:
  News:
    type: Extbase
    limitToPages:
      - 104
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/'
        _controller: 'News::list'
      - routePath: '/page-{page}'
        _controller: 'News::list'
        _arguments:
          page: '@widget_0/currentPage'
      - routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      - routePath: '/{category-name}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
      - routePath: '/{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
    defaultController: 'News::list'
    defaults:
      page: '0'
    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: slug
      tag-name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug

不需要的参数

实际上,像&tx_news_pi1[day]=20&tx_news_pi1[month]=7这样的日期参数是NOT默认值,这意味着您复制了一些TS片段,其中包括它,或者您的一些同事将它放在那里。

根据News的Humane可读日期文档,在您的TypoScript中搜索plugin.tx_news.settings.link.hrDate节点,并修改或删除它,以消除单视图链接中的日期参数。

最后,如果你想保留它们,但有人类可读的URL,请查看ext:news的最新文档,其中有一个带有方面的适当日期路由示例。

我找到了解决方案。问题不在于路由,而是原始新闻URL包含了所有额外的参数{天}{月}{年}。以下SETUP(设置(设置可关闭此功能:

plugin.tx_news.settings.link.hr日期=0

通过禁用它,生成的原始URl如下所示:?tx_news_pi1[action]=细节&tx_news_pi1[controller]=新闻&tx_news_pi1[news]=486&cHash=

它现在运行得很好。感谢biesior把我推向解决方案!

相关内容

最新更新