Search code examples
fluidtypo3-flow

Is it possible to use the same view for two diffrent actions?


i am trying to share one view with two actions from the same controller and i am quite struggling. Is it even possible?


Solution

  • By default Fluid expects a template in Resources/Private/Templates/ControllerName/ActionName.html

    So each action expects its own template. If I understand you correctly, you want two different ations to use the same Fluid-Template. You can achieve this in two different ways:

    1. Use Partials:

    Just put your hole Fluid-Template of action A to a partial and render that partial in the template for acion A and action B with:

    <f:render partial="YourPartial" />
    

    So you have two templates, but both are rendering the same partial.


    2. Set the template for action B to be the template of action A:

    You can overwrite the default template of an action with:

    $this->view->setTemplatePathAndFilename($templatePathAndFilename);
    

    You need to give the full path to a template file. Then Fluid will use this template instead of the default one.

    Note: The 2nd suggestion is woking in TYPO3 CMS, but since extbase is backportet from flow, it should be possible to do this in flow as well.