本文介绍了如何在 TYPO3 9.5.5 中正确设置 tx-news 的 url-routing?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 TYPO3 V9.5.5 和 PHP V7.2.10.还安装了 tx-news 插件.站点配置已设置并正常工作.但是,如果我为新闻详细信息添加 routeEnhancers,它不会在 url 中显示它.它总是看起来像:norefer..info/aktuell/detail?tx_news_pi1%5Bnews%5D=5&cHash=c68f25c1ef4b5bd7320220373cfed332

I use TYPO3 V9.5.5 with PHP V7.2.10. Also there is tx-news plugin installed. The site configuration is set and works. But if I add routeEnhancers for news detail it doesnt't show it in the url. It always looks like: http://p510984.mittwaldserver.info/aktuell/detail?tx_news_pi1%5Bnews%5D=5&cHash=c68f25c1ef4b5bd7320220373cfed332

我在 stackoverflow 和 google 中搜索了解决方案.我还阅读了新闻扩展手册 https://docs.typo3.org/typo3cms/extensions/news/stable/AdministratorManual/BestPractice/Routing/

I searched for solutions in stackoverflow and google. Also I read the manual of the news extension https://docs.typo3.org/typo3cms/extensions/news/stable/AdministratorManual/BestPractice/Routing/

即使是 TYPO3 和 PHP 缓存刷新也无济于事.

Even TYPO3 and PHP cache flushing doesn't help.

目前我有以下代码:

routeEnhancers:
  NewsPlugin:
    type: Extbase
    limitToPages:
      - 17
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
    defaultController: 'News::list'
    defaults:
      page: '0'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment

是否需要defaultController and defaults: page: 0"?

Does it need "defaultController and defaults: page: 0"?

推荐答案

对我来说,这个方案效果很好:

For me this one worked well:

routeEnhancers:
  # news rewrites
  News:
    type: Extbase
    #limitToPages:
    #  - 67
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '/{news-title}', _controller: 'News::detail', _arguments: { news-title: news } }
      #- { routePath: '/cat/{news-cat}', _controller: 'News::list', _arguments: { news-cat: overwriteDemand/categories } }
    defaultController: 'News::list'
    defaults:
      page: '0'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      news-cat:
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: slug

这篇关于如何在 TYPO3 9.5.5 中正确设置 tx-news 的 url-routing?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 18:00