1

I have an issue using the News extension and Infinite Scrolling plugin on TYPO3 9.5.11.

What I am looking for is to set up 2 infinite scrollings : one to list every news, another one to list news by categories (using the list by category). It works, but when I list my news by category I can't get a readable URL like in the other scroll (for example I get *categorie/page-2?tx_news_pi1[action]=list&tx_news_pi1[controller]=News&tx_news_pi1[overwriteDemand][categories]=3&cHash=6ff5f6ee014fec754b5453d9c4afdcc1* instead of categorie/nameofthecategory/page-X). I hope it is clear enough.

Here is my 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' 

Does someone know how to set this up?

Thanks! :-)

EDIT : Ok so I found out that using this config.yaml kinda works :

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'

The problem with this setup is that I encounter the bug explained here : Bug #86895 - routeEnhancer not working correct for paginate widget. It means on my main page, if I put the url */2 and load the first page, I get an incorrect URL. For whatever reason, I don't encounter it in my category-filtering page...

I tried applying the patch mentionned in Forge, no success unfortunatly.

1 Answers1

0

Ok so I finally figured out the solution. I completely forgot that you can specify a page on which a specified route works. Here is the final version :

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'

This way the plugin-based router works on the main page (even if I come from page 2 to 1) and I can use the EXTBase-based route for the category.