Search code examples
typo3typoscripttypo3-8.x

HMENU Browse - show linkWrap even if ATagTitle is empty (TYPO3 8.7.x)


I use the following Typoscript for a special menu. Of course there is no linkWrap right now if ATagTitle.dataWrap is empty. What is the best way to have   as content of the ATagTitle.dataWrap if {field:title} is empty so that the linkWrap is used?

  [treeLevel = 3,4,5]
        lib.navHorizon = COA
        lib.navHorizon {
            stdWrap.wrap = <nav class="row nav_horizontal">|</nav>
            10 = HMENU
            10 {
                special = browse
                special {
                    items = prev
                }

            1 = TMENU
            1.noBlur = 1
            1.NO {
                ATagTitle.dataWrap = {field:title}
                linkWrap = <div class="d-none d-md-block col-4 nav_prev"><i class="fa fa-angle-double-left"></i> |</div>    
            }
        }

        25 = HMENU
        25 {
            special = browse
            special {
                items = up
            }

            1 = TMENU
            1.noBlur = 1
            1.NO {
                ATagTitle.dataWrap = {field:title}
                linkWrap = <div class="d-none d-md-block col-4 nav_up">|</div>
            }
        }

        20 = HMENU
        20 {
            special = browse
            special {
                items = next
            }

            1 = TMENU
            1.noBlur = 1
            1.NO {
                ATagTitle.dataWrap = {field:title}
                linkWrap = <div class="d-none d-md-block col-4 order-3 nav_next">| <i class="fa fa-angle-double-right"></i></div>
            }
        }
    }

[global]

Extended explanation: I have a row with three columns. If the first column containing the link to the previous page is empty, the HTML for the column is also missing, so the layout is no longer correct.


Solution

  • From your additional information I understand the problem is not that the title is empty, but that there's no page at all. So if there's not previous page, it will not "execute" lib.navHorizon.10.1 at all.

    You can fix this by not setting the wrap on the link, but on the HMENU:

    10 = HMENU
    10 {
      special = browse
      special {
        items = prev
      }
    
      wrap = <div class="d-none d-md-block col-4 nav_prev"><i class="fa fa-angle-double-left"></i> |</div>    
    
      1 = TMENU
      1.noBlur = 1
      1.NO {
        ATagTitle.dataWrap = {field:title}
      }
    }
    

    This will ensure the wrap is always rendered, even if there's no page.