【问题标题】:TYPO3 Routing: List & Details Action on same PageTYPO3 路由:同一页面上的列表和详细信息操作
【发布时间】:2019-02-06 12:55:20
【问题描述】:

访问详情页时抛出异常:The action "details" (controller "Products") is not allowed by this plugin.

我的 Route Enhancer 如下所示:

ProductsPlugin:
  type:              Extbase
  extension:         Myext
  plugin:            Products
  routes:
    -
      routePath:   '/{product_slug}'
      _controller: 'Products::details'
      _arguments:
        product_slug: productId
  defaultController: 'Products::list'
  defaults:
    productId: '0'
  aspects:
    product_slug:
      type: ProductsValueMapper

插件是通过TypoScript嵌入的:

lib.productsContent = USER
lib.productsContent {
    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    extensionName = Myext
    pluginName = Products
    vendorName = Vendor

    switchableControllerActions {
        Products {
            1 = list
        }
    }
}

[request.getQueryParams()['tx_myext_products']['productId'] > 0]
    lib.productsContent.switchableControllerActions.Products.1 = details
[end]

Fluid-Template 中的链接由以下人员生成:

<f:link.action class="button more" pageUid="38" action="details" arguments="{productId: '{product.product.id}'}">Mehr</f:link.action>

我尝试在 _controllerdefaultController 的列表和详细信息之间切换。我也尝试删除一个或两个,但生成的链接包含 GET-Params 或 Detailview 会创建上面的错误消息。

谁能把我推向正确的方向?

提前致谢!

编辑: 当我删除 _controller: 'Products::details' 时,错误消息消失了,我的详细信息操作被正确调用。但是,详细信息操作的链接包含常规的 GET 参数。

【问题讨论】:

    标签: typo3 typo3-9.x


    【解决方案1】:

    问题是插件在同一页面上多次嵌入,导致问题。

    要解决这个问题,您可以创建不同的插件或设置plugin.tx_myext_products.mvc.callDefaultActionIfActionCantBeResolved = 1

    见:https://wiki.typo3.org/Exception/CMS/1313855175

    【讨论】:

    • 我像您一样在同一页面上使用同一插件的多个实例,并且我还设置了“callDefaultActionIfActionCantBeResolved = 1”,但我仍然无法生成正确的 URL。我不通过打字稿包含插件,而是通过插件内容元素和 flexform 可切换控制器操作。如果我删除路由增强器中的“_controller”部分,则正确的 URL(如(/product/example))仍然可以访问,但通过 f:link.action 或 f:link.typolink 在其他站点上生成 URL 将无法正常工作如上所述。所以默认操作对我不起作用:(。
    【解决方案2】:

    你能检查一下这个补丁吗? https://review.typo3.org/c/59343/包括我在内的两个人遇到了同样的问题。

    【讨论】:

    • 感谢补丁。但不幸的是,结果还是一样。我也更新了我的帖子。
    猜你喜欢
    • 2023-04-08
    • 1970-01-01
    • 2021-09-14
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    • 2014-01-02
    • 2016-03-25
    • 1970-01-01
    相关资源
    最近更新 更多