#88811Allow the use of variable from a actioncontroller in section "headerAssets" and "footerAssets"
Description
I want to use the variable of my controller-action in a footerAssets-section in my template. I need it to generate a page-specific javascript-code.
<f:section name="FooterAssets">
<footer>
<f:debug>{pageTest}</f:debug>
<f:render section="debugFooterAssets"
arguments="{pageTest:pageTest}"
/>
</footer>
</f:section>
The variables of the action are not avaiable in this special sections.
The solution of the problem seems to need only a change in typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php. in line 196 (TYPO3 9.5.8)
// old version
$variables = ['request' => $request, 'arguments' => $this->arguments];
// suggested solution
$variables = $this->view->getRenderingContext()->getVariableProvider()->getAll();
$variables['request'] = $request;
$variables['arguments'] = $this->arguments;Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 4
-
Claus Due commented and changed tracker
BugFeature priorityShould haveCould have 07/27/19, 16:25 -
Claus Due commented and changed category 07/27/19, 16:25
Category set to Extbase since this exclusively relates to the ActionController.
-
Dieter Porth commented 08/08/19, 06:46
There are three resaon for my idea.
1. There is no indication of the limitation of this system part in the documentation. The mistake is unexspected.
2. The typical way of TYPO3 to overcome restrictions is via hooks or signal&slots. The overwriting is untypical for TYPO3
3. How do I override the restrictions on third-party extensions? I can override their templates but not their controllers, can’t I. -
Georg Ringer commented and changed status
NewClosed 03/31/25, 18:28Hey,
quite some time passed by. Now you can do that with the asset viewhelpers, e.g.
<f:asset.script identifier="demo">alert("{page.id}");</f:asset.script>therefore closing the issue
More variables can be added if necessary, but I would advise against:
The more appropriate way is to skip Fluid for such complex assets, which is done by overriding:
Should you need additional variables they can be inserted here. The method is intended for overriding exactly for that use case.
I’ve changed the issue to a feature request and set to “could have” because overriding the method is already possible, as is use of a custom ViewHelper to retrieve whichever context you require. It needs to be carefully considered which variables, if any, to add to the default set. The current chosen variables are considered safe – arbitrary variables from context made available to Fluid may not be safe.