Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
Section ViewHelper <f:section>
A ViewHelper to declare sections in templates for later use with e.g. the f:render
ViewHelper.
Examples
Rendering sections
<f:section name="someSection">This is a section. {foo}</f:section>
<f:render section="someSection" arguments="{foo: someVariable}" />
Copied!
Output:
the content of the section "someSection". The content of the variable {someVariable} will be available in the partial as {foo}
Copied!
Rendering recursive sections
<f:section name="mySection">
<ul>
<f:for each="{myMenu}" as="menuItem">
<li>
{menuItem.text}
<f:if condition="{menuItem.subItems}">
<f:render section="mySection" arguments="{myMenu: menuItem.subItems}" />
</f:if>
</li>
</f:for>
</ul>
</f:section>
<f:render section="mySection" arguments="{myMenu: menu}" />
Copied!
Output:
<ul>
<li>menu1
<ul>
<li>menu1a</li>
<li>menu1b</li>
</ul>
</li>
[...]
(depending on the value of {menu})
Copied!
Source code
Go to the source code of this ViewHelper: SectionViewHelper.php (GitHub).
Arguments
The following arguments are available for <f:
:
name
-
- Type
- string
- Required
true
Name of the section