无限滚动、分页和路线

Infinite Scroll, pagination and routes

我在 TYPO3 9.5.11 上使用新闻扩展和无限滚动插件时遇到问题。

我正在寻找的是设置 2 个无限滚动:一个列出所有新闻,另一个按类别列出新闻(使用类别列表)。它有效,但是当我按类别列出我的新闻时,我无法像在其他卷轴中那样获得可读的 URL(例如,我得到 *categorie/page-2?tx_news_pi1[action]=list&tx_news_pi1[controller]=News&tx_news_pi1[overwriteDemand][categories]=3&cHash=6ff5f6ee014fec754b5453d9c4afdcc1* 而不是 categorie/nameofthecategory/page-X)。我希望它足够清楚。

这是我的config.yaml:

routeEnhancers:
  News:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      -
        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
      category-name:
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: slug
      tag-name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug
  NewsList:
    type: Plugin
    routePath: '/page-{@widget_0/currentPage}'
    namespace: 'tx_news_pi1'
    aspects:
      '@widget_0/currentPage':
        type: StaticRangeMapper
        start: '1'
        end: '1000' 

有人知道如何设置吗?

谢谢! :-)

编辑:好的,所以我发现使用这个 config.yaml 有点管用:

routeEnhancers:
  News:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      -
        routePath: '/{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: '/{category-name}/{page}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
          page: '@widget_0/currentPage'
    defaultController: 'News::list'
    defaults:
      page: '1'
    requirements:
      page: '\d+'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      category-name:
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: slug
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'

此设置的问题是我遇到了此处解释的错误:Bug #86895 - routeEnhancer not working correct for paginate widget。这意味着在我的主页上,如果我放置 url */2 并加载第一页,我会得到不正确的 URL。无论出于何种原因,我都没有在我的类别过滤页面中遇到它...

我尝试申请 the patch mentionned in Forge,不幸的是没有成功。

好的,所以我终于找到了解决方案。我完全忘记了您可以指定指定路由在其上运行的页面。这是最终版本:

routeEnhancers:
  News:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      -
        routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      - routePath: '/{category-name}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
      -
        routePath: '/{category-name}/{page}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
          page: '@widget_0/currentPage'
    defaultController: 'News::list'
    defaults:
      page: '1'
    requirements:
      page: '\d+'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      category-name:
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: slug
      page:
        type: StaticRangeMapper
        start: '1'
        end: '1000'
  NewsList:
    type: Plugin
    limitToPages: [3] #(3 is my main's page pid)
    routePath: '/{@widget_0/currentPage}'
    namespace: 'tx_news_pi1'
    aspects:
      '@widget_0/currentPage':
        type: StaticRangeMapper
        start: '1'
        end: '1000'

这样,基于插件的路由就可以在主页上工作(即使我是从第 2 页到第 1 页),而且我可以为类别使用基于 EXTBase 的路由。