0
votes

I want to create a menu with submenu, that's quiet straight forward via typoscript. The challenge is, that I want the parent levels to link directly to the first subpage if the content of the containing page is empty.

I know you can achieve that via shortcut links in the backend, but I want to, if possible, achieve that via typoscript.

Any ideas? I enclode the typoscript menu code I currently use.

lib.mainMenu = COA
lib.mainMenu{
10 = HMENU
10{
        # Level 1, further levels are generic
        1 = TMENU
        1.noBlur = 1
        1.expAll = 0
        1.wrap = <ul data-role="listview" data-inset="true">|</ul>
        1.NO = 1
        1.NO.ATagBeforeWrap = 1
        1.NO.insertData = 1
        1.NO.wrapItemAndSub.insertData = 1
        1.NO.wrapItemAndSub = <li id="menu_{field:uid}">|</li>
        1.NO.ATagTitle.field = subtitle // title

        1.ACT = 1
        1.ACT.ATagBeforeWrap = 1
        1.ACT.wrapItemAndSub.insertData = 1
        1.ACT.wrapItemAndSub = <li id="menu_{field:uid}" class="active">|</li>
        1.ACT.ATagTitle.field = subtitle // title

        1.CUR = 1
        1.CUR.ATagBeforeWrap = 1
        1.CUR.wrapItemAndSub.insertData = 1
        1.CUR.wrapItemAndSub = <li id="menu_{field:uid}" class="active">|</li> 
        1.CUR.ATagTitle.field = subtitle // title

}
20 < .10
20.entryLevel = 1
20.1.wrap = <ul data-role="listview" data-inset="true">|</ul>
30 < .20
30.entryLevel = 2
40 < .20
40.entryLevel = 3
}
2

2 Answers

0
votes

Maybe you can build your solution based on hints from here: http://typo3-blog.net/tutorials/news/if-funktionen-in-typo3.html

In the example from the link above, it's not a menu, but there's a subquery on a table (in your case tt_content) which will then be used to define if something's output or not:

temp.main = COA
temp.main.20 = COA
temp.main.20 {
  [...]
  wrap=&lt;div class="meine-adressen"&gt;|&lt;/div&gt;
  stdWrap.if.isTrue.cObject = CONTENT
  stdWrap.if.isTrue.cObject{
    table = tt_address
    select {
      [...]
    }
  renderObj = TEXT
  renderObj.value = 1
  }
}

temp.main.21 = TEXT
temp.main.21 {
  wrap=&lt;div class="keine-adressen"&gt;|&lt;/div&gt;
  value = Keine Adressen gefunden
  stdWrap.if.isFalse.cObject < temp.main.20.stdWrap.if.isTrue.cObject
}

But I'm not sure if this wouldn't give you headaches in a HMENU

0
votes

I think it is possible using typoscript, but I dont know how to do it. The below typoscript may help you:

Typoscript to find the number of content elements in a page:

lib.emptypage = CONTENT
lib.emptypage{
    table = tt_content
    select{
      selectFields = count(uid) AS count
      pid = id
    }
    renderObj = COA
    renderObj {
      10 = TEXT
      10 {
        value = {field:count}
        insertData = 1
      }
    }
    wrap = |
}

If count is equal to zero, then the page is empty.

Typoscript to get the first subpage:

lib.firstsubpage= HMENU
lib.firstsubpage {
    maxItems = 1
    1 = TMENU
    1 {
        NO = 1
    }
}

Please share your typoscript solution after implementing it.