sualko
(Klaus Herberth)
September 9, 2015, 1:00pm
#1
Hi guys,
I try to create a template which distinguishes between the case if the submenu has elements or not.
My typoscript looks like this:
parts {
secondMenu = Menu {
entryLevel = 2
maximumLevels = 1
}
}
and template:
<div class="col-sm-9" id="main-content">
<f:if condition="{parts.secondMenu}">
<f:then>
<div class="col-sm-3">
{parts.secondMenu -> f:format.raw()}
</div>
<div class="col-sm-8 col-sm-offset-1">
{content.main -> f:format.raw()}
</div>
</f:then>
<f:else>
{content.main -> f:format.raw()}
</f:else>
</f:if>
</div>
What is the correct condition? I tried also {parts.secondMenu.items}
or also a different typoscript variables like hasItems = ${q(node).children()}
.
Thank you in advance.
aertmann
(Aske Ertmann)
September 10, 2015, 12:32pm
#2
Hi Klaus
Problem is that the menu always outputs a wrapper, regardless of being empty.
You can solve it in two ways:
Remove output from menu if it’s empty
secondMenu.@process.emptyIfNoItems = ${Array.count(this.items) > 0 ? value : ‘’}
You can check if the page has children
hasItems = ${q(node).closest([’_depth=3’]).children(’[instanceof TYPO3.Neos:Document][_hiddenInIndex = false]’).is()}
Didn’t test this, but should give you some pointers.
Cheers,
Aske
sualko
(Klaus Herberth)
September 10, 2015, 1:05pm
#3
First way does not fit my use case and second one results in the following erro:
filter operation expects string argument
page<TYPO3.Neos:Page>/
body<TYPO3.TypoScript:Template>/
hasSecondMenu<>/
But this works:
hasItems = ${q(node).siblings('[instanceof TYPO3.Neos:Document][_hiddenInIndex = false]') && q(node).parents('[instanceof TYPO3.Neos.NodeTypes:Page]')}
Thank you for your help.
sualko
(Klaus Herberth)
September 10, 2015, 1:06pm
#4
Can I close this in any way?
aertmann
(Aske Ertmann)
September 13, 2015, 8:13am
#5
Good to hear. You’re welcome.
Not sure if you’re allowed to do it, but if you are you can click the wrench icon in the bottom fo the thread and select “Close Topic”. Let me know if it’s not possible for you.
sualko
(Klaus Herberth)
September 14, 2015, 8:08pm
#6
I think I am not allowed to do so, because there are only buttons for bookmark, share, reply and watching.
Think this feature would increase productivity of this forum.