You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TYPO3 v10下多命名空间与多部分参数的URL美化方案问询

Kitodo.Presentation(TYPO3 v10)URL美化解决方案:多命名空间与嵌套参数处理

针对Kitodo.Presentation在TYPO3 v10下的URL美化需求,以下是两类复杂场景的可行配置方案:

一、多命名空间共存场景处理

当URL同时包含tx_dlf[id]和tx_dlf_navigation[controller]这类不同命名空间的参数时,可在路由配置中为每个命名空间单独定义映射规则,确保参数能被正确解析与美化。

示例配置:

routeEnhancers:
  KitodoDlf:
    type: Simple
    limitToPages: [123] # 替换为你的Kitodo页面ID
    routePath: '/document/{id}/{controller}'
    requirements:
      id: '\d+'
      controller: '[a-zA-Z]+'
    defaults:
      controller: 'Navigation'
    aspects:
      id:
        type: StaticRangeMapper
        start: '1'
        end: '9999'
      controller:
        type: StaticValueMapper
        map:
          browse: 'Browse'
          navigation: 'Navigation'
    _arguments:
      id: 'tx_dlf[id]'
      controller: 'tx_dlf_navigation[controller]'

二、多部分嵌套参数处理

对于tx_dlf_listview[searchParameter][collection]这类多层嵌套参数,可直接在_arguments字段中完整声明嵌套参数路径来实现映射。

示例配置:

routeEnhancers:
  KitodoListview:
    type: Simple
    limitToPages: [456] # 替换为你的列表页面ID
    routePath: '/search/{collection}'
    requirements:
      collection: '[a-zA-Z0-9_-]+'
    aspects:
      collection:
        type: StaticValueMapper
        map:
          manuscripts: 'manuscript_collection'
          prints: 'print_collection'
    _arguments:
      collection: 'tx_dlf_listview[searchParameter][collection]'

三、整合两类场景的完整配置

将两类规则整合到同一个配置文件中,通过limitToPages限定作用页面,避免路由冲突:

routeEnhancers:
  # 处理文档查看与导航的多命名空间规则
  KitodoDlf:
    type: Simple
    limitToPages: [123]
    routePath: '/document/{id}/{controller}'
    requirements:
      id: '\d+'
      controller: '[a-zA-Z]+'
    defaults:
      controller: 'Navigation'
    aspects:
      id:
        type: StaticRangeMapper
        start: '1'
        end: '9999'
      controller:
        type: StaticValueMapper
        map:
          browse: 'Browse'
          navigation: 'Navigation'
    _arguments:
      id: 'tx_dlf[id]'
      controller: 'tx_dlf_navigation[controller]'

  # 处理列表搜索的嵌套参数规则
  KitodoListview:
    type: Simple
    limitToPages: [456]
    routePath: '/search/{collection}'
    requirements:
      collection: '[a-zA-Z0-9_-]+'
    aspects:
      collection:
        type: StaticValueMapper
        map:
          manuscripts: 'manuscript_collection'
          prints: 'print_collection'
    _arguments:
      collection: 'tx_dlf_listview[searchParameter][collection]'

关键配置说明

  • limitToPages:将路由规则限定到特定Kitodo页面,避免全局路由冲突
  • _arguments:支持直接映射跨命名空间参数与多层嵌套参数
  • aspects:实现参数的友好别名转换,提升URL可读性
  • requirements:通过正则表达式限定参数格式,确保路由解析准确

内容的提问来源于stack exchange,提问作者BFallert

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 23:54:58