4.1.4 Controller actions

FluidTYPO3 File contexts, Controllers

Your template files inside for example the Content subfolder are - according to Extbase conventions - connected directly to a Controller's action. In standard Extbase, the Controller action must exist first and will then cause the template file to be rendered - in Fluid Powered TYPO3 this is reversed (since your Controller is optional): the template file should first and foremost exist and if a Controller and Controller action can be resolved which match the template, it will then be used. This is the reason why even when your Controller class contains no action methods, it will still be able to render the template file (and internally in Flux, this is because a fallback action - renderAction() - exists on the AbstractFluxController class).

If for example you have a template file in EXT:myext/Resources/Private/Templates/Content/MyElement.html the corresponding Controller action would be named myElementAction (note the required Action suffix; without it your action will not be seen). Inside your controller action you can then perform operations which for example are very complex in Fluid or require access to request parameters, session variables and such.

public function myElementAction() {
    $special = $this->doSomethingSpecialTo($this->settings['someValue']);
    $this->view->assign('mySpecialVariable', $special);
}

Now, whenever your MyElement.html template gets rendered (by fluidcontent in this case) your special Controller class will be created and the action called, causing your special code to execute and the {mySpecialVariable} Fluid variable to be assigned.

Jump to...