相关疑难解决方法(0)

关于如何为 ext:news 的列表和详细视图设置路由增强器的良好实践?

前提

ext:news 列表视图插件位于 www.domain.com/news [ID 9] 页面上,详细视图位于 www.domain.com/article [ID 39] 上。

按照官方示例(docs.typo3.org)

我尝试了功能描述的“Extbase插件增强器”示例,但这引起了一些问题:

  • 页面浏览器链接到第 2 页有一个 cHash:news/list/2?cHash=123456789
  • 从第 2 页到第 1 页的 pagebrowser 链接有很多获取参数: news?tx_news_pi1%5Baction%5D=list&tx_news_pi1%5Bcontroller%5D=News&cHash=123456789 。如果没有routeEnhancer,它就只是没有任何获取参数的“新闻”。
  • 详细视图的链接有一个 cHash:article/blog/9?cHash=52e8a4b7c6318cfe0273e7eab374e9ae
  • 网址包含不需要的段(“列表”+“博客”)
  • acticle url 不包含新闻标题

造成某些问题的原因之一可能是分页器未在其链接中指定控制器:news?tx_news_pi1[@widget_0][currentPage]=2&cHash=123456789

我的方法,已经解决了提到的问题

我将其拆分为两个单独的路由增强器(Extbase + 插件),删除了“defaultController”、“defaults”、“requirements”段并添加了“aspects”:

routeEnhancers:
  NewsDetail:
    type: Extbase
    limitToPages: [39]
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
    aspects:
      news_title:
        type: PersistedAliasMapper
        tableName: 'tx_news_domain_model_news'
        routeFieldName: 'path_segment'
  NewsList:
    type: Plugin
    limitToPages: [9]
    routePath: '/{@widget_0/currentPage}'
    namespace: 'tx_news_pi1'
    aspects:
      '@widget_0/currentPage':
        type: …
Run Code Online (Sandbox Code Playgroud)

typo3 extbase typo3-extensions tx-news typo3-9.x

4
推荐指数
1
解决办法
3363
查看次数

标签 统计

extbase ×1

tx-news ×1

typo3 ×1

typo3-9.x ×1

typo3-extensions ×1