Render ViewHelper <f:render>

Go to the source code of this ViewHelper: RenderViewHelper.php (GitHub).

Rendering a partial

The render ViewHelper can be used with the argument partial to render the content of a "partial". A partial is a separate Fluid file.

packages/my_site_package/Resources/Private/PageView/Pages/Default.html
<f:render partial="Footer" arguments="{_all}"/>
Copied!

During rendering the content of file packages/my_site_package/Resources/Private/PageView/Partials/Footer.html will be rendered with all variables that are also available in the main template.

It is possible to render a partial within a partial or layout as well. For example the footer partial could look like this:

packages/my_site_package/Resources/Private/PageView/Partials/Footer.html
<footer class="my-footer">
    <f:render partial="Navigation/FooterMenu" arguments="{_all}"/>
</footer>
Copied!

When the argument partial contains a slash / the partial will be searched in a subfolder. The partial from the above example will therefore be expected in file packages/my_site_package/Resources/Private/PageView/Partials/Navigation/FooterMenu.html.

Configuring the path in which to save the partials

Rendering a section

When the render ViewHelper is used with the argument section the content of a Section ViewHelper <f:section> can be rendered.

packages/my_site_package/Resources/Private/PageView/Layouts/PageLayout.html
<f:render section="SomeSection"/>

<f:section name="SomeSection">
    This is the section.
</f:section>
Copied!

Rendering sections in layouts

If the section is rendered from within a layout file the section can be defined in the template using the layout. Since usually several templates use the same layout, it can be helpful to mark the render tag as optional. It is also possible to provide a default value to be displayed if the section was not found in the template. You can use the content of the tag or the argument default.

packages/my_site_package/Resources/Private/PageView/Layouts/PageLayout.html
<f:render section="Header" optional="true">
    <f:render partial="Header" arguments="{_all}"/>
</f:render>
<f:render section="Breadcrumb" optional="true"/>
<f:render section="Main"/>
Copied!

In this example the templates may define a section called "Header" to override the default header rendered from a partial.

If the template defines no section named "Breadcrumb" that section is just ignored.

All templates have to define the section "Main" otherwise there is an error.

Template 1 just defines some content:

packages/my_site_package/Resources/Private/PageView/Pages/Template1.html
<f:layout name="PageLayout"/>
<f:section name="Main">
    <main>Main content of Template 1</main>
</f:section>
Copied!
packages/my_site_package/Resources/Private/PageView/Pages/Template2.html
<f:layout name="PageLayout"/>
<f:section name="Header">
    <header>My Special header</header>
</f:section>
<f:section name="Breadcrumb">
    <f:render partial="Navigation/Breadcrumb" arguments="{_all}">
</f:section>
<f:section name="Main">
    <main>Main content of Template 1</main>
</f:section>
Copied!

Rendering a section from a (different) partial

If both arguments section and partial are used a section found in a partial can be rendered.

Arguments

arguments

arguments
Type
array
Default
array ( )
Array of variables to be transferred. Use {_all} for all variables

contentAs

contentAs
Type
string
If used, renders the child content and adds it as a template variable with this name for use in the partial/section

debug

debug
Type
boolean
Default
true
If true, the admin panel shows debug information if activated,

default

default
Type
mixed
Value (usually string) to be displayed if the section or partial does not exist

delegate

delegate
Type
string
Optional PHP class name of a permanent, included-in-app ParsedTemplateInterface implementation to override partial/section

optional

optional
Type
boolean
Default
false
If true, considers the *section* optional. Partial never is.

partial

partial
Type
string
Partial to render, with or without section

section

section
Type
string
Section to render - combine with partial to render section in partial