TYPO3路由增强新闻存档DateMenu和分页的功能

问题描述

使用config.yaml中的以下行,我在TYPO3中配置新闻插件的URL。存档的URL(年/月)看起来像预期的一样,但不起作用。我收到错误404。

  • / year / 2020/07 /
  • / year / 2020/08 /
  • 依此类推

删除注释# Date year/month:# Date year/month + pagination:下面的两部分时,我看到存档链接看起来像这样:

  • / 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
  • 依此类推

感兴趣的部分是/page-0/,它不应该在那儿,但来自分页器。删除认部分中的page: '0'后,分页不再起作用...

我在配置中缺少什么吗?

我的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: {  }

更新

使用两种不同的配置,我几乎可以正常工作:

#####################################################
########## 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

信用:hereIdentifierValueMapperexotec手中夺走了!

最后一个问题:存档页面上的分页

常规分页链接/page-2/)会导致错误404,而月份分页/year/2020/08/page-2/)则不考虑月份和年份。

结论: 如果两个配置都处于活动状态(在存档页面上就是这种情况),则它们会互相干扰。

任何提示都值得赞赏!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)