Skip to content

Instantly share code, notes, and snippets.

@aertmann
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aertmann/10022207 to your computer and use it in GitHub Desktop.
Save aertmann/10022207 to your computer and use it in GitHub Desktop.
You can do it with a simple template object. Here's an example:
contentMenu = TYPO3.TypoScript:Template {
templatePath = 'resource://Moc.Net/Private/Templates/TypoScriptObjects/ContentMenu.html'
items = ${q(node).children('[instanceof TYPO3.Neos:ContentCollection]').children('[instanceof Moc.Net:SectionGrid][showInContentMenu = true]')}
}
{namespace moc=Moc\Net\ViewHelpers}
<f:if condition="{items}">
<ul>
<f:for each="{items}" as="item">
<li>
<a href="#{item.properties.header -> moc:slugify()}" class="content-menu-item">{item.properties.header -> f:format.stripTags()}</a>
</li>
</f:for>
</ul>
</f:if>
We've used a slugify view helper to turn the title into an id which we also use for the content elements we're creating a menu for. You can also just use the identifier (usually something like 1a490c12-c30e-cab2-de08-03096cddf7ed) by using {item -> f:format.identifier()} and then make sure that is also done to your content elements. That can be done using the attributes for the content wrapping. Example:
prototype(TYPO3.Neos:Content) {
attributes.id = ${node.identifier}
}
or the name (usually something like node52697bdfee199)
prototype(TYPO3.Neos:Content) {
attributes.id = ${node.name}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment