image

TYPO3 Typoscript Generate menu with its parent title

Some times we need a menu with its parent title in the same level.

 

Ex : Page tree Home
  page 1
  page 2
    subpage 1
    subpage 2
  page 3

and we need menu like

First level
 Home
 page 1
 page 2
 page 3

Second level
 page 2
 subpage 1
 subpage 2

This can be done with following code

10 = HMENU
10 {
stdWrap.wrap = <ul class="menu"> | </ul>
entryLevel = 0
1 = TMENU
1.stdWrap.wrap.stdWrap.cObject = COA
1.stdWrap.wrap.stdWrap.cObject {
10 = TEXT
10.stdWrap.typolink.parameter.data = field:pid
10.stdWrap.wrap = <li> | </li>
}
1 {
expAll = 1
NO = 1
NO.wrapItemAndSub = <li> | </li>
ACT < .NO
ACT.wrapItemAndSub = <li class="active"> | </li>
CUR < .NO
CUR.wrapItemAndSub = <li class="active current"> | </li>
}
2 < .1
2.wrap = <ul class="sumenu second-level">| </ul>
3 < .1
3.wrap = <ul class="sumenu third-level">| </ul>
}