gpt4 book ai didi

typo3 - 如何使用 FluidTypo3 将参数传递给 Controller ​​操作?

转载 作者:行者123 更新时间:2023-12-02 01:27:05 26 4
gpt4 key购买 nike

我必须如何将参数传递给启用通量的 Controller ,以便 Controller 操作识别它?

我使用构建器创建了一个扩展并将以下方法添加到 ContentController。

/**
* @param string $var
*/
public function exampleAction($var = null) {
var_dump($var);
die;
}

但是无论我如何将参数添加到 URL 中,结果都只会得到“null”。

扩展目录是“test”, $_EXTKEY 也是。构建器将“Mac.Test”放入 ext_tables.php 以调用 registerProviderExtensionKey()。所以在 URL 中我尝试了这些参数:
http://host/index.php?id=1&tx_test_content[var]=abc
http://host/index.php?id=1&tx_test[var]=abc
http://host/index.php?id=1&tx_mactest_content[var]=abc
http://host/index.php?id=1&tx_mactest[var]=abc
http://host/index.php?id=1&var=abc

和其他一些。但无济于事。

我尝试使用 f:link.action ViewHelper,结果是 http://localhost/test2/index.php?id=1&no_cache=1&tx_test_content[member]=foo&tx_test_content[action]=example&tx_test_content[controller]=Content
另外 $this->request->getArguments() 只返回一个空数组,所以一定有什么严重的错误。

使用过的版本:
PHP 5.6.11
TYPO3 6.2.21
视频 2.4.0
通量 7.2.3
流体页面 3.3.1
流体含量 4.3.3
流体内容核心 1.3.0
build 者 1.0.0
没有安装其他任何东西(新系统只是为了测试这种行为)。

最佳答案

使用流体链接,您可以像传递一样

<f:link.action action="example" controller="controllerName"  arguments="{var:'abc'}">Go</f:link.action>

它将创建如下链接:
http://host/index.php?id=1&tx_[extension_key]_[fe_plugin_key][var]=abc

现在,如何从 extBase 中的 url 获取 para
$arguments = $this->request->getArguments(); // OR
$var = $this->request->getArgument('var');

有用的链接:
  • Fluid
  • extBase Accessing GET/POST vars
  • 关于typo3 - 如何使用 FluidTypo3 将参数传递给 Controller ​​操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36505001/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com