How to pass argument to controller action with FluidTypo3?

D. E. picture D. E. · Apr 8, 2016 · Viewed 10.8k times · Source

How do I have to pass an argument to a flux-enabled controller so it is recognized by the controller action?

I created an extension using builder and added the following method to the ContentController.

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

But no matter how I add the parameter to the URL, I only get "null" as a result.

Extensions directory is "test" and so is $_EXTKEY. The builder put "Mac.Test" into ext_tables.php for calls to registerProviderExtensionKey(). So in the URL I tried these parameters:

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

and some others. But to no avail.

I tried with the f:link.action ViewHelper, resulting in
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

Also $this->request->getArguments() only returns an empty array, so there must be something seriously wrong.

Used versions:
PHP 5.6.11
TYPO3 6.2.21
vhs 2.4.0
flux 7.2.3
fluidpages 3.3.1
fluidcontent 4.3.3
fluidcontent_core 1.3.0
builder 1.0.0
Nothing else installed (fresh system just for testing this behaviour).

Answer

Ghanshyam Gohel picture Ghanshyam Gohel · Apr 12, 2016

Using fluid link, you can pass para like

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

It'll create link like:

http://host/index.php?id=1&tx_[extension_key]_[fe_plugin_key][var]=abc

Now, how to get para from url in extBase

$arguments = $this->request->getArguments(); // OR
$var = $this->request->getArgument('var');

Useful links: