0
votes

I have a page structure like so:

- About us (lvl 1)
  -- About us 1 (lvl 2)
  -- About us 2 (lvl 2)
  -- About us 3 (lvl 2)
     --- Detail about us 3 (lvl 3)
     --- Detail about us 3 (lvl 3)
  -- About us 4 (lvl 2)
- Our great products (lvl 1)
  -- Great products (lvl2)
   --- Detail great products (lvl 3)

Each lvl 2 page has a right-hand menu showing all the other lvl2 pages with the same lvl1 parent. It's rendered with Typoscript like this:

 lib.side_buttons_submenu = CONTENT
 lib.side_buttons_submenu {
   table = pages
   select {
     orderBy = sorting
         recursive = 0
         selectFields = uid, subtitle
   }
   renderObj  = TEXT
   renderObj  {
     field = subtitle
     required = 1
     typolink.parameter.field = uid
     wrap = <li>|</li>
   }
   wrap = |
 }

This outputs:

  <ul class="side_buttons">
   <li>About us 1</li>
   <li>About us 2</li>
   <li>About us 3</li>
   <li>About us 4</li>
  </ul>

I want to add the lvl3 pages beneath the lvl 2 pages, and add class="parent" if the page has subpages, so the side menu looks like this:

 <ul class="side_buttons">
   <li>About us 1</li>
   <li>About us 2</li>
   <li class="parent">About us 3
       <ul> 
           <li>Detail about us 3</li>
           <li>Detail about us 3</li>
       </ul>
   </li>
   <li>About us 4</li>
</ul>

I can't find an example of this anywhere in the Typoscript documentation- does anyone have a snippet to show me how to do it?

1

1 Answers

0
votes

With help from the answers to this question, I finally got it! This renders a lvl2 + lvl3 menu with a class of "parent" on lvl2 items with subpages:

lib.side_buttons_submenu = HMENU
lib.side_buttons_submenu {

entryLevel = 1

1 = TMENU
1 {

    expAll = 1

    NO.field = subtitle
    NO.required = 1
    NO.typolink.parameter.field = uid
    NO.linkWrap = <li>|</li>

    IFSUB = 1
    IFSUB.wrapItemAndSub= <li class="parent">|</li>

    ACTIFSUB < .IFSUB
    CURIFSUB < .IFSUB

    ACT < .NO
    ACT = 1
    ACT.linkWrap = <li class="current">|</li>

}

2 = TMENU
2 {
    wrap = <ul>|</ul>
    NO = 1
    NO.wrapItemAndSub = <li>|</li>
}
}