How to pass argument to controller action with FluidTypo3?

12,111

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:

Share:
12,111
D. E.
Author by

D. E.

PHP, Symfony, TYPO3. In this order :) I prefer to not just answer as many questions as possible, but to give high quality answers with lots of helpful background information. At least I try. I spend much time on these answers and thus am really grateful for receiving upvotes, accepted answers, etc. Thanks! :)

Updated on August 21, 2022

Comments

  • D. E.
    D. E. over 1 year

    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).

  • D. E.
    D. E. about 8 years
    Thanks for this try, but unfortunately it doesn't change anything. In fact I at first tried to generate the link via f:link.action ViewHelper and as that had no impact at all, I tried with other URL parameters. I should have noted that, though. $this->request->getArguments() returns an empty array. And even if it returned the value, I would lose lots of magic (like resolving a parameter to a fully loaded model). So unfortunately your tips don't help :(