0

With the below lines in the config.yaml, I configure the URLs for the news plugin in TYPO3. The URLs for the archive (year/month) look like expected, but don't work. I get an error 404.

  • /year/2020/07/
  • /year/2020/08/
  • and so on

When removing the two parts below the comments # Date year/month: and # Date year/month + pagination: I can see, that the archive links look like this:

  • /page-0/?tx_news_pi1[overwriteDemand][month]=08&tx_news_pi1[overwriteDemand][year]=2020&cHash=3f6c75083013c748da3870210647975b
  • /page-0/?tx_news_pi1[overwriteDemand][month]=07&tx_news_pi1[overwriteDemand][year]=2020&cHash=26bf541eb04daffaa9b43c033ea2bb90
  • and so on

The interestion part is the /page-0/ which shouldn't be there but comes from the paginator. After removing the page: '0' in the defaults section, the pagination isn't working anymore...

Am I missing something in my configuration?

My config.yaml:

base: '/'
baseVariants: {  }
errorHandling: {  }
languages:
  -
    title: Deutsch
    enabled: true
    base: /
    typo3Language: de
    locale: de_DE.UTF-8
    iso-639-1: de
    navigationTitle: ''
    hreflang: ''
    direction: ''
    flag: de
    languageId: '0'
rootPageId: 1
routeEnhancers:
  PageTypeSuffix:
    type: PageType
    default: /
    index: ''
    map:
      /: 0
  #################################
  ########## News Plugin ##########
  #################################
  # see https://docs.typo3.org/p/georgringer/news/master/en-us/AdministratorManual/BestPractice/Routing/Index.html#human-readable-dates
  NewsConfig:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      # Pagination:
      - routePath: '/'
        _controller: 'News::list'
      - routePath: '/page-{page}'
        _controller: 'News::list'
        _arguments:
          page: '@widget_0/currentPage'
        requirements:
          page: '\d+'
      - routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      # Date year/month:
      - routePath: '/year/{date-year}/{date-month}'
        _controller: 'News::list'
        _arguments:
          date-month: 'overwriteDemand/month'
          date-year: 'overwriteDemand/year'
          page: '@widget_0/currentPage'
        requirements:
          date-month: '\d+'
          date-year: '\d+'
      # Date year/month + pagination:
      - routePath: '/year/{date-year}/{date-month}/page-{page}'
        _controller: 'News::list'
        _arguments:
          date-month: 'overwriteDemand/month'
          date-year: 'overwriteDemand/year'
          page: '@widget_0/currentPage'
        requirements:
          date-month: '\d+'
          date-year: '\d+'
          page: '\d+'
    defaultController: 'News::list'
    defaults:
      page: '0'
      date-month: ''
      date-year: ''
    aspects:
      news-title:
        type: PersistedPatternMapper
        tableName: tx_news_domain_model_news
        routeFieldPattern: '^(?P<path_segment>.+)-(?P<uid>\d+)$'
        routeFieldResult: '{path_segment}-{uid}'
      page:
        type: StaticRangeMapper
        start: '1'
        end: '500'
      date-month:
        type: StaticRangeMapper
        start: '1'
        end: '12'
      date-year:
        type: StaticRangeMapper
        start: '2000'
        end: '2030'
routes: {  }

UPDATE

With two different configurations I got it almost to work:

#####################################################
########## News detail page and pagination ##########
#####################################################
NewsGeneral:
  type: Extbase
  extension: News
  plugin: Pi1
  routes:
    - routePath: '/{news-title}'
      _controller: 'News::detail'
      _arguments:
        news-title: news
    - routePath: '/page-{page}'
      _controller: 'News::list'
      _arguments:
        page: '@widget_0/currentPage'
      requirements:
        page: '\d+'
  defaultController: 'News::list'
  defaults:
    page: '1'
  aspects:
    news-title:
      type: PersistedPatternMapper
      tableName: tx_news_domain_model_news
      routeFieldPattern: '^(?P<path_segment>.+)-(?P<uid>\d+)$'
      routeFieldResult: '{path_segment}-{uid}'
    page:
      type: IdentifierValueMapper
#########################################
########## News archive config ##########
#########################################
# see https://docs.typo3.org/p/georgringer/news/master/en-us/AdministratorManual/BestPractice/Routing/Index.html#human-readable-dates
NewsArchiveConfig:
  type: Extbase
  extension: News
  plugin: Pi1
  limitToPages:
    - 19
    - 313
  routes:
    # Date year/month:
    - routePath: '/year/{date-year}/{date-month}'
      _controller: 'News::list'
      _arguments:
        date-month: 'overwriteDemand/month'
        date-year: 'overwriteDemand/year'
    # Date year/month + pagination:
    - routePath: '/year/{date-year}/{date-month}/page-{page}'
      _controller: 'News::list'
      _arguments:
        date-month: 'overwriteDemand/month'
        date-year: 'overwriteDemand/year'
        page: '@widget_0/currentPage'
      requirements:
        date-year: '\d+'
        date-month: '\d+'
        page: '\d+'
  defaultController: 'News::list'
  aspects:
    date-month:
      type: IdentifierValueMapper
    date-year:
      type: IdentifierValueMapper
    page:
      type: IdentifierValueMapper

Credits: The IdentifierValueMapperwas taken from here, thanks to exotec!

One last problem: The pagination on the archive pages.

The normal pagination link (/page-2/) leads to an error 404 and a month pagination (/year/2020/08/page-2/) does no respect the month and the year.

Conclusion: If both configurations are active (which is the case on the archive page), they are interfering with each other.

Any hint is appreciated!

chris
  • 2,109
  • 2
  • 23
  • 33
  • At least some of the answer is here: https://stackoverflow.com/questions/54669488/typo3-9-add-date-to-url-routing-enhancers-for-news-extension . Also, you can't create more than 10,000 items in a single route enhancer; there's a limit to prevent cache flooding attacks. You're making a lot more than that (30*12*500). Use fewer pages and years. See the bottom of this documentation page: https://docs.typo3.org/p/georgringer/news/master/en-us/AdministratorManual/BestPractice/Routing/Index.html#human-readable-dates – phvt Sep 09 '20 at 11:28
  • @phvt I used now a custom mapper in order to overcome the limit of the `StaticRangeMapper` and added some more information. – chris Sep 10 '20 at 18:22

0 Answers0