Feature #88811

Allow the use of variable from a actioncontroller in section "headerAssets" and "footerAssets"

Added by Dieter Porth 5 months ago. Updated 4 months ago.

Status:
New
Priority:
Could have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2019-07-21
Due date:
% Done:

0%

PHP Version:
7.2
Tags:
Complexity:
Sprint Focus:

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;

History

#1 Updated by Claus Due 4 months ago

  • Tracker changed from Bug to Feature
  • Priority changed from Should have to Could have

More variables can be added if necessary, but I would advise against:

  • Indiscriminately inserting all variables
  • Inserting variables extracted from an already-rendered view
  • Using variables which are not part of the request hash (as changing those changes the asset but not the other output)

The more appropriate way is to skip Fluid for such complex assets, which is done by overriding:

  • ActionController->renderAssetsForRequest($request)

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.

#2 Updated by Claus Due 4 months ago

  • Category set to Extbase

Category set to Extbase since this exclusively relates to the ActionController.

#3 Updated by Dieter Porth 4 months ago

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.

Also available in: Atom PDF