[TYPO3-english] How can I give each menu item a different class? (optionSplit?)

Jörg Klein joerg at klein-family.com
Mon Dec 31 14:20:29 CET 2012


Hi Philipp,

"Philipp Gampe" schrieb:
>> I think the solution
>> must be somewhere there, inside the HMENU TypoScript code...
>
> So you want to use something like:
> NO.wrapItemAndSub.dataWrap = <li class="no 
> {register:count_MENUOBJ}">|</li>

Basically yes. :-)

I now got it solved: It _is_ possible by using optionSplit!

The TMENUITEM states have optionSplit. With optionSplit you can use "||" to 
define separate subparts. For each of these subparts you can then provide an 
own rendering instruction. The first subpart will be used for the first 
page, the second for the second page and so forth.

So what I do is this:

  HEAD = HMENU
  HEAD {
    # Level 1
    1 = TMENU
    1 {
      NO = 1
      NO {
        wrapItemAndSub = <ul class="selectable one"><li>|</li></ul> || <ul 
class="selectable two"><li>|</li></ul> || <ul class="selectable 
three"><li>|</li></ul>
      }
      ACT = 1
      ACT {
        wrapItemAndSub = <ul class="current one"><li>|</li></ul> || <ul 
class="current two"><li>|</li></ul> || <ul class="current 
three"><li>|</li></ul>
      }
    }
  }


The above instructions render the supplied classes for the first three menu 
items. If you have more items, you can just add the next subparts to 
.wrapItemAndSub.

Happy New Year!

Jörg 




More information about the TYPO3-english mailing list