smic/dynamic-routing-pages

动态生成 "limitToPages" 配置,以便您不需要硬编码它。

安装次数: 66,613

依赖项: 0

建议者: 0

安全性: 0

星标: 18

关注者: 4

分支: 8

开放问题: 8

类型:typo3-cms-extension

1.1.0 2024-04-30 06:30 UTC

This package is auto-updated.

Last update: 2024-09-09 09:02:23 UTC


README

此包可以自动检测您所需的页面并动态生成配置,而不是为您的路由增强器硬编码 limitToPages 配置。

问题

想象以下典型的新闻插件路由配置。

routeEnhancers:
  NewsPages:
    type: Extbase
    # add every page-ID that contains a News Plugin
    limitToPages:
      - 23
      - 42
      - 123
      - 242
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '/{myNewsTitle}', _controller: 'News::detail', _arguments: {'myNewsTitle': 'news'} }
      - { routePath: '/{myPagination}', _controller: 'News::list', _arguments: {'myPagination': '@widget_0/currentPage'} }
      - { routePath: '/{year}/{month}', _controller: 'News::list', _arguments: {'year' : 'overwriteDemand/year', 'month' : 'overwriteDemand/month'} }
    defaultController: 'News::list'
    # ...

对于您的插件路由硬编码页面ID的主要缺点是,每当有人创建一个新的包含插件的页面时(可能在CMS中发生),您必须调整配置。由于在网站模块中没有路由增强器配置,这意味着每次编辑器创建插件页面时,您都必须发送一个更新的配置文件。

解决方案

routeEnhancers:
  NewsPages:
    type: Extbase
    dynamicPages:
        withPlugin: news_pi1
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '/{myNewsTitle}', _controller: 'News::detail', _arguments: {'myNewsTitle': 'news'} }
      - { routePath: '/{myPagination}', _controller: 'News::list', _arguments: {'myPagination': '@widget_0/currentPage'} }
      - { routePath: '/{year}/{month}', _controller: 'News::list', _arguments: {'year' : 'overwriteDemand/year', 'month' : 'overwriteDemand/month'} }
    defaultController: 'News::list'
    # ...

注意 dynamicPages 配置。此包将使用匹配的页面填充 limitToPages

参考

dynamicPages 有三个可能的属性。

withPlugin

可以是字符串或 tt_content.list_type 值的数组。将找到包含至少一个给定插件的全部页面。

containsModule

可以是字符串或 pages.module 值的数组。将找到设置为给定值之一的“包含插件”的所有页面。

withSwitchableControllerAction

可以是字符串或 switchableControllerActions 值的数组。将找到包含具有给定操作的插件的全部页面。

withCType

可以是字符串或 withCType 值的数组。将找到包含具有给定 CType 的内容元素的全部页面。

withDoktypes

可以是整数或 withDoktypes 值的数组。将找到具有给定 doktype 的全部页面。