簡體   English   中英

在 Typo3 routeEnhancer 中設置默認參數的問題

[英]Problem with setting default argument in Typo3 routeEnhancer

我有一個 Typo3 頁面,它使用兩個 URL 參數,“手稿”和“類型”(例如 localhost/my-page?manuscript=samplemanuscript&type=description)。 “手稿”是必填參數,而“類型”是可選參數。

我使用 Route Enhancers 去除 URL 中的 cHash。所以我創建了一個 yaml 文件來配置它。

此配置在沒有“默認”部分且兩個參數都已到位的情況下工作正常,但是當我添加默認部分以使“類型”參數可選時,URL localhost/my-page/samplemanuscript 工作正常,但 localhost/my-page/samplemanuscript /description 顯示 404 錯誤。 任何想法有什么問題嗎?

我使用 Typo3 v10.4

routeEnhancers:
  ManuscriptHierarchy:
    type: Simple
    limitToPages: [13]
    routePath: '/{manuscript}/{type}'
    defaults:
      type: ''
    aspects:
      manuscript:
        type: StaticValueMapper
        map:
          samplemanuscript: samplemanuscript
          samplemanuscript2: samplemanuscript2
      type:
        type: StaticValueMapper
        map:
          transcription: transcription
          description: description

聚苯乙烯

出於調試目的,是否有任何適當的方法來檢查最終解析的 URL(當我訪問 localhost/my-page/samplemanuscript/description 時)?

該解決方案對我來說看起來很奇怪,但它通過添加要求來工作:

routeEnhancers:
  ManuscriptHierarchy:
    type: Simple
    limitToPages: [13]
    routePath: '/{manuscript}/{type}'
    defaults:
      type: ''
    requirements:
      manuscript: '^(?:samplemanuscript|samplemanuscript2)$'
      type: '^(?:description|transcription)$'
    aspects:
      manuscript:
        type: StaticValueMapper
        map:
          samplemanuscript: samplemanuscript
          samplemanuscript2: samplemanuscript2
      type:
        type: StaticValueMapper
        map:
          transcription: transcription
          description: description

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM