0

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

  • /年/2020/07/
  • /年/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

致谢:感谢exotec IdentifierValueMapper _

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

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

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

任何提示表示赞赏!

4

0 回答 0