Php 无限滚动、分页和路由

Php 无限滚动、分页和路由,php,routing,typo3,typo3-9.x,tx-news,Php,Routing,Typo3,Typo3 9.x,Tx News,我在TYPO3 9.5.11上使用新闻扩展和无限滚动插件时遇到了一个问题 我正在寻找的是设置2个无限滚动:一个列出每一条新闻,另一个按类别列出新闻(使用按类别列出)。它可以工作,但当我按类别列出我的新闻时,我无法获得像另一个卷轴中那样可读的URL(例如,我得到的是*categorie/page-2?tx\u news\u pi1[action]=list&tx\u news\u pi1[controller]=news&tx\u news\u pi1[overwriteDemand][categ

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

我正在寻找的是设置2个无限滚动:一个列出每一条新闻,另一个按类别列出新闻(使用按类别列出)。它可以工作,但当我按类别列出我的新闻时,我无法获得像另一个卷轴中那样可读的URL(例如,我得到的是
*categorie/page-2?tx\u news\u pi1[action]=list&tx\u news\u pi1[controller]=news&tx\u news\u pi1[overwriteDemand][categories]=3&cHash=6ff5f6ee014fec754b5453d9c4afdcc1*
,而不是
categorie/name/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'
此设置的问题是我遇到了此处解释的错误:。这意味着在我的主页上,如果我放入url
*/2
并加载第一页,我会得到一个错误的url。无论出于什么原因,我在分类过滤页面中都没有遇到它


我试着申请,不幸的是没有成功。

好的,所以我终于找到了解决办法。我完全忘记了您可以指定一个页面,在该页面上指定的路由可以工作。以下是最终版本:

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的路由进行分类。

好的,所以我终于找到了解决方案。我完全忘记了您可以指定一个页面,在该页面上指定的路由可以工作。以下是最终版本:

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的路由进行分类