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
相关产品推荐
相关产品推荐

