Reputation: 99
Edit: Before you start, please consider that in my original post, the condition i used for illustrating the problem was confusing. I marked it now with ###. This was just meant for showing that i needed an if condition like solution. However, an if condition with brackets [] doesn't work at that point in typoscript. See the solutions down below, which uses override.if. This works perfectly fine!
In a tmenu, created with typoscript, i want to wrap the items differently, according to the title of the pages they belong to. I use Foundation for the width of the elements and therefor the classe large-4. Now the basic wrapping (wrapitemandsub) is no problem, however there is one page with a longer title and i'd need to use the class large-8. In the following code I wrote a condition with an invalid expression, just to demonstrate you how it should behave.
This is the script for the navigation:
lib.content_menu = COA
lib.content_menu {
1 = HMENU
1 {
entryLevel = 0
1 = TMENU
1 {
expAll = 1
NO {
### [current pagetitle == somevalue]
wrapItemAndSub = <li class="columns small-8 large-8 active">|</li>wrap
### [ELSE]
wrapItemAndSub = <li class="columns small-4 large-4">|</li>
### [END]
}
ACT = 1
ACT {
wrapItemAndSub = <li class="columns small-4 large-4 active">|</li>
}
CUR = 1
CUR < .ACT
IFSUB = 1
IFSUB {
ATagParams = onclick='return false;'
wrapItemAndSub = <li class="columns small-4 large-4">|</li>
}
ACTIFSUB = 1
ACTIFSUB {
ATagParams = onclick='return false;'
wrapItemAndSub = <li class="columns small-4 large-4 active">|</li>
}
CURIFSUB = 1
CURIFSUB < .ACTIFSUB
}
2 = TMENU
2 {
wrap = <ul class="menu vertical">|</ul>
NO {
wrapItemAndSub = <li>|</li>
}
CUR = 1
CUR {
wrapItemAndSub = <li class="active">|</li>
}
}
}
}
Can anyone help me on this? :)
Upvotes: 0
Views: 114
Reputation: 2685
In your context you can use .if or .override - find out more about them in TSRef: https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/If/Index.html https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Stdwrap/Index.html#override
Try it like this:
wrapItemAndSub = <li class="columns small-4 large-4">|</li>
wrapItemAndSub.override = <li class="columns small-8 large-8 active">|</li>
wrapItemAndSub.override.if.value = titletocheck
wrapItemAndSub.override.if.equals.field = title
Upvotes: 1