Documentation · ViewHelper reference

RenderViewHelper


ViewHelper that renders a section or a specified partial

Examples

Rendering partials

<f:render partial="SomePartial" arguments="{foo: someVariable}" />

Output

the content of the partial "SomePartial". The content of the variable {someVariable} will be available in the partial as {foo}

Rendering sections

<f:section name="someSection">This is a section. {foo}</f:section>
<f:render section="someSection" arguments="{foo: someVariable}" />

Output

the content of the section "someSection". The content of the variable {someVariable} will be available in the partial as {foo}

Rendering recursive sections

<f:section name="mySection">
 
    <f:for each="{myMenu}" as="menuItem">
  • {menuItem.text} <f:if condition="{menuItem.subItems}"> <f:render section="mySection" arguments="{myMenu: menuItem.subItems}" /> </f:if>
  • </f:for>
</f:section> <f:render section="mySection" arguments="{myMenu: menu}" />

Output

  • menu1
    • menu1a
    • menu1b
  • [...] (depending on the value of {menu})

Passing all variables to a partial

<f:render partial="somePartial" arguments="{_all}" />

Output

the content of the partial "somePartial".
Using the reserved keyword "_all", all available variables will be passed along to the partial

  • Tag usage example

    <f:render section="NULL" partial="NULL" arguments="{foo: 'bar'}" optional="1">
    	<!-- tag content - may be ignored! -->
    </f:render>
  • Inline usage example

    {f:render(section: 'NULL', partial: 'NULL', arguments: {foo: 'bar'}, optional: 1)}

Arguments

Argument Description Type
arguments

Arguments to pass to the partial.

array
optional

Set to TRUE, to ignore unknown sections, so the definition of a section inside a template can be optional for a layout

boolean
partial

Reference to a partial.

string
section

Name of section to render. If used in a layout, renders a section of the main content file. If used inside a standard template, renders a section of the same file.

string
Required attribute

Revision history

commit 785ba07f9c52130d0e2d94f78aea45bbfbe6d20c
Author: Sebastian Kurfürst <*****@typo3.org>
Date:   Mon Aug 3 10:52:32 2009 +0000

    [+BUGFIX] Fluid (View): Refactored TemplateView, which is now automatically backported to FLOW3
    [+FEATURE] Fluid: Added Layout and Partial support. This adds <f:render>, <f:layout> and <f:section> as ViewHelpers. See the blog example for an example.
    [!!!] [~TASK] Fluid (ViewHelpers): Updated AbstractFormViewHelper and SelectViewHelper. Everything should still work as expected, but here there might still be some issues. Please test thoroughly and report any problems!

commit 9b2830bc1c17588dd69a463773c5f05f61b5cf94
Author: Sebastian Kurfürst <*****@typo3.org>
Date:   Sat Oct 24 11:01:38 2009 +0000

    * A*****@api annotations
    * Changed the fluid-specific RuntimeException to SPL's RuntimeException.

commit 7868047c52417ff4e1f3e99e45adaba1ee3d0a24
Author: Sebastian Kurfürst <*****@typo3.org>
Date:   Sat Oct 24 11:49:45 2009 +0000

    [~TASK] Fluid: A*****@package and @subpackage annotations.

commit 06372a84a645147029501d2b2b06a4fdfe56b7d7
Author: Michael Stucki <*****@typo3.org>
Date:   Wed Nov 25 21:53:57 2009 +0000

    Add missing SVN properties for new or modified files

commit 73120f54db03414430e147384fb1c5ed7ce81e48
Author: Sebastian Kurfürst <*****@typo3.org>
Date:   Fri Jun 18 09:19:33 2010 +0000

    [+BUGFIX] Fluid (Core): Putting form fields in partial now works as expected. Resolves #4277.

commit ed19fe9e4a6d2e91c594784adea24aa82064dd47
Author: Sebastian Kurfürst <*****@typo3.org>
Date:   Mon Jul 12 20:18:26 2010 +0000

    Fluid in v5 and v4 are now synchronized again!
    
    [+FEATURE] Fluid: The TemplateVariableContainer now provides a method to retrieve all variables.
    [~TASK] Fluid (Core): Introduced a RenderingContextInterface to more cleanly decouple Fluid's rendering context from the TypoScript rendering context. Note that view helpers (and other code) should now refer to that interface instead of the concrete Fluid implementation!
    [!!!][+BUGFIX] Fluid (Core): Refactored all Condition-ViewHelpers like f:if, f:security.if* to use a newly created base class F3\Fluid\Core\ViewHelper\ConditionViewHelper. This greatly simplifies the implementation of custom conditions. However, THIS IS A BREAKING CHANGE in case you copied the f:if ViewHelper to create a custom condition ViewHelper, as the internal workings changed. Please check the new f:if ViewHelper to see how to adjust your ViewHelper -- you basically just have to throw away a lot of code. Resolves #8824.
    [!!!][-API] Fluid (TemplateView): Removed renderSection() and renderWithLayout() from public API in Tx_Fluid_View_TemplateView, as this should only be called from inside Fluid.
    [!!!][TASK] Fluid (ViewHelpers): the <f:section />-ViewHelper now does NOT render itself anymore when encountered in a normal template. Example: Before the change, the template "before <f:section name='...'> middle </f:section> after" was rendered as "before middle after", but now it is only rendered as "before after". Although this is a breaking change, it is quite unlikely that anybody relied on this behavior, as it was inconsistent beforehand.
    [TASK] Fluid (TemplateView): Major refactoring of the layout, partial and section rendering mechanism. This also induces a speedup as retundant rendering is eliminated.
    [+FEATURE] Fluid (ViewHelpers): The <f:render>-ViewHelper can be now used to render sections in the same partial and template. In these cases, all arguments need to be specified explicitely. Additionally, it can now be used to render a section recursively.
    [~TASK] Fluid (Core): Removed some non-API-methods which were never called.

commit 186bdaeac89820779f91853b830cc95d60c7ad58
Author: Bastian Waidelich <*****@typo3.org>
Date:   Tue Jul 13 09:42:26 2010 +0000

    [-TASK] Fluid: R*****@version annotation from all Fluid classes to ease the backporting process. Relates to #8835 (backported from Fluid package)

commit 1d36de6ed90007e324b773782e8f0a1d1c1191a2
Author: Bastian Waidelich <*****@typo3.org>
Date:   Tue Jul 13 10:12:30 2010 +0000

    [-TASK] Fluid: R*****@package/@subpackage annotations from all Fluid classes. They have already been removed in FLOW3 packages in r2813.

commit dc77ba679530634d4a6b520bf6317fa5caa83d6a
Author: Sebastian Kurfürst <*****@typo3.org>
Date:   Wed Sep 22 06:27:58 2010 +0000

    [+FEATURE] Fluid (Core): {settings} is available in Partials
    
    Now, the {settings} are automatically available in partials and sections.
    Before, they had to be passed explicitely, i.e. by calling
    <f:render section="..." arguments="{settings: settings}" />.
    
    If somebody defined his own "settings"-argument, this still takes precedence:
    <f:render section="..." arguments="{settings: some.different.settings}" />
    This means that this change is completely backwards compatible.
    
    NOTE: The settings are NOT merged together, like it has been suggested in #6289,
    as this will lead to un-obvious behavior for the user.

commit 85a0b640045402d713cdb26636ff144cd295e1f1
Author: Sebastian Kurfürst <*****@typo3.org>
Date:   Wed Sep 22 06:28:15 2010 +0000

    [+BUGFIX] Fluid (ViewHelpers): RenderViewHelper works with TYPO3
    
    In I14c6dd4d9db13a98f1873a79bb43fbf299d2c835, we have introduced
    a change which caused the Menu generation in TYPO3 Phoenix to crash,
    as {settings} is not available in these templates.
    
    Now, a check has been added which checks for {settings} being present.
    
    Additionally, a unit test has been written testing this behavior.

commit 472451987ca0530fa5828bb0b79fcafa2f905a35
Author: Bastian Waidelich <*****@typo3.org>
Date:   Fri Nov 19 20:58:09 2010 +0000

    [-TASK] Fluid: R*****@scope annotations as they are not used in v4

commit dd8928aed4c119d8db37322acb91ded24ba5cc35
Author: Bastian Waidelich <*****@typo3.org>
Date:   Thu Dec 30 16:21:11 2010 +0000

    [+TASK] Fluid (ViewHelpers): Fix, cleanup and extend inline documentation of ViewHelpers
    
    Resolves #10908

commit 4a98afd0e39afc1e2023682835752b8f6faf6dde
Author: Bastian Waidelich <*****@typo3.org>
Date:   Thu Jul 28 13:57:40 2011 +0200

    [!!!][+FEATURE] Add a reserved variable {_all} returning all template variables
    
    This is especially helpful for passing all arguments
    to a partial, using
    <f:render partial="..." arguments="{_all}" />
    
    Note: This is a breaking change only if you used the variable "_all" in your template.
    In that case just rename that variable to a non-reserved string.
    
    Change-Id: Ifa534dcf72ff8d391e93ab4a4e822c65a13b7985

commit 6a7bf379dfc55d3e6d48d2b6518aa42b03054cfb
Author: Bastian Waidelich <*****@typo3.org>
Date:   Wed Sep 7 15:52:51 2011 +0200

    [FEATURE] Add parameter to RenderViewHelper for optional sections
    
    This change adds an additional parameter to allow optional sections
    that will be rendered as an empty string if they were not defined
    by a template.
    
    Usage:
    <f:render section="someOptionalSection" optional="true" />
    
    Change-Id: I46ee53ff93742c4049e9dad1a16201e45b081a4b

commit fd09d197fa8886b97cb20aa9573f39cd08ce989e
Author: Bastian Waidelich <*****@typo3.org>
Date:   Thu Nov 10 18:27:58 2011 +0100

    [TASK] S*****@author annotations
    
    This backports three recent changes of the TYPO3.Fluid package:
    - R*****@license annotation from files (290f4f5)
    - Simplify license header in PHP files (14bacba)
    - D*****@author tags from source code (9c2e837)
    
    This should not contain any functional change!
    
    Change-Id: I9376dca4af78c4f0f82413011d115b8ad04634dd

commit ca40f8a066da4ea3c849d74f68a9bc73758976c5
Author: dkd-egerer Sascha Egerer <*****@dkd.de>
Date:   Sat Apr 14 21:43:10 2012 +0200

    [TASK] Remove trailing whitespace
    
    There must be no empty lines after the closing
    PHP tag. Empty lines after closing tags break
    output compression in PHP and/or result in AJAX
    errors.
    
    Change-Id: I0484ca29d8134d0828cf30880d5aafd43ed9d78e
    Resolves: #36076
    Releases: 6.0
    Reviewed-on: http://review.typo3.org/10499
    Reviewed-by: Ingo Pfennigstorf
    Tested-by: Ingo Pfennigstorf
    Reviewed-by: Daniel Lorenz
    Tested-by: Daniel Lorenz
    Reviewed-by: Christian Kuhn
    Tested-by: Christian Kuhn

commit ec3891d8d4e339d8319428211207e6201be9fd73
Author: Thomas Maroschik <*****@dfau.de>
Date:   Wed Oct 17 21:18:26 2012 +0200

    [TASK][WIP] Move non class code back to source files
    
    Change-Id: I620d2e61860142cdc89cc83474c95542799961c0

commit 554e8f890dcc0dd86a27518b58e2b54be26fd37e
Author: Thomas Maroschik <*****@dfau.de>
Date:   Wed Oct 17 22:20:17 2012 +0200

    [TASK] Namespace classes
    
    Change-Id: Ia7432e1c923826ed58206bca15fb94509adbd508

commit 9d13dedf017b614b834261b1bf5d4acb2201f1d4
Author: Alexander Schnitzler <*****@typovision.de>
Date:   Fri Nov 16 19:49:02 2012 +0100

    [CLEANUP] Replace FLOW3 with TYPO3 Flow
    
    Releases: 6.0
    Fixes: #43036
    Change-Id: I62df23587301b4cde3ddeae3686b34f54fe1182e
    Reviewed-on: http://review.typo3.org/16498
    Reviewed-by: Alexander Schnitzler
    Tested-by: Alexander Schnitzler

commit 9d46e6932d35c79bf87c96fa38b8e537c4192f23
Author: Alexander Schnitzler <*****@typovision.de>
Date:   Tue Nov 20 16:27:02 2012 +0100

    [CLEANUP] Adjust code to CGL and fix small namespace bugs
    
    * whitespaces, tabs and blank line issues
    * bool -> boolean
    * int -> integer
    * fix wrong namespace annotations
    
    Fixes: #43157
    Releases: 6.0
    Change-Id: I8397948e19248db029d8efd1555ee56e4982742d
    Reviewed-on: http://review.typo3.org/16619
    Reviewed-by: Helmut Hummel
    Tested-by: Helmut Hummel

commit 50d433bbde06b4b9eab146caea64d09239949e64
Author: Tymoteusz Motylewski <*****@gmail.com>
Date:   Sun Mar 3 18:53:42 2013 +0100

    [TASK] Sync CMS Fluid with Flow Fluid 1.1 (part2)
    
    This is the second part of a backport fluid from Flow.
    
    Change-Id: I96e47131414c50801ff7628508dc05d7d7b5e106
    Releases: 6.1
    Resolves: #44819
    Fixes: #45985
    Reviewed-on: https://review.typo3.org/18163
    Reviewed-by: Wouter Wolters
    Tested-by: Wouter Wolters
    Reviewed-by: Marc Bastian Heinrichs
    Tested-by: Marc Bastian Heinrichs

commit 77f29a3c69a7cbb27b34072754aa503bace6c9f1
Author: Christian Kuhn <*****@schwarzbu.ch>
Date:   Tue Oct 1 14:40:56 2013 +0200

    [TASK] Remove closing PHP tags
    
    Change-Id: Iaa92566c53301e49396fc9fb26b0b339c48d567b
    Resolves: #52360
    Releases: 6.2
    Reviewed-on: https://review.typo3.org/24212
    Reviewed-by: Christian Kuhn
    Tested-by: Christian Kuhn
    Reviewed-by: Ernesto Baschny
    Tested-by: Ernesto Baschny
    Reviewed-by: Anja Leichsenring
    Tested-by: Anja Leichsenring