Skip to content

Instantly share code, notes, and snippets.

@jrenggli
Created August 18, 2014 15:47
Show Gist options
  • Save jrenggli/22425abb448df9d3a044 to your computer and use it in GitHub Desktop.
Save jrenggli/22425abb448df9d3a044 to your computer and use it in GitHub Desktop.
TYPO3 Neos: hide subItems in menu when node is not active (behaviour similar to expAll = 0 in TYPO3 CMS)
{namespace neos=TYPO3\Neos\ViewHelpers}
{namespace ts=TYPO3\TypoScript\ViewHelpers}
<ul{attributes -> f:format.raw()}>
<f:render section="itemsList" arguments="{items: items}" />
</ul>
<f:section name="itemsList">
<f:for each="{items}" as="item">
<li{ts:render(path:'{item.state}.attributes') -> f:format.raw()}>
<neos:link.node node="{item.node}">{item.label}</neos:link.node>
<f:if condition="{item.subItems}">
<f:comment>Hide subItems if current node is not active</f:comment>
<f:if condition="{item.state} != 'normal'">
<ul>
<f:render section="itemsList" arguments="{items: item.subItems}" />
</ul>
</f:if>
</f:if>
</li>
</f:for>
</f:section>
page = Page {
...
body {
...
parts {
menu = Menu {
templatePath = 'resource://Swisscom.VorsorgeregionalbankenSite/Private/Templates/TypoScriptObjects/Menu.html'
attributes.class = 'nav'
entryLevel = 1
maximumLevels = 3
current.attributes.class = 'current'
active.attributes.class = 'active'
normal.attributes.class >
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment