简体   繁体   中英

Typo3 Submenu TMENU with if, when HMENU pid is equals

I have an HMENU with a submenu and I want to add a third submenu, if the main menu point has the uid xxx.

If I implement this TypoScript Code, all third submenus will be shown:

3 = TMENU
3 {
    stdWrap.outerWrap = <div class="submenu-third-level"><ul class='submenu'>|</ul></div>
    stdWrap.outerWrap.override = <div class="submenu-third-level show"><ul class='submenu'>|</ul></div>
    stdWrap.outerWrap.override.if {
        value.data = field:pid
        isInList = 588
    }
    stdWrap.insertData = 1
    NO.wrapItemAndSub = <li class="menu-item">|</li>

    ACT = 1
    ACT{
        wrapItemAndSub = <li class="menu-item active">|</li>
    }

    SPC = 1
    SPC {
       doNotLinkIt = 1
       doNotShowLink = 1
       allWrap = </ul><ul class='submenu'>
    }
}

Thus, all submenus of submenus will be shown. But I want to only show the submenus of submenus in HMENU PID XXX.

Is there a possibility to do it like:

   3 = TMENU
    3 {
        stdWrap.outerWrap = <div class="submenu-third-level"><ul class='submenu'>|</ul></div>
        stdWrap.outerWrap.override = <div class="submenu-third-level show"><ul class='submenu'>|</ul></div>
        stdWrap.outerWrap.override.if {
            value.data = field:pid
            isInList = 588
        }
        stdWrap.insertData = 1
        NO.wrapItemAndSub = <li class="menu-item">|</li>

        ACT = 1
        ACT{
            wrapItemAndSub = <li class="menu-item active">|</li>
        }

        SPC = 1
        SPC {
           doNotLinkIt = 1
           doNotShowLink = 1
           allWrap = </ul><ul class='submenu'>
        }

        if {
            value.data = field:pid
            equals = xxx
        }
    }

Look you better use new HMENU like:

lib.mainmenu = HMENU
...{
1 = TMENU
...
2 = TMENU
} # so just two levels
lib.tempmenu <. lib.mainmenu # just save your menu

[PIDinRootline = xxx] 
#or [globalVar = TSFE:id=xxx]
lib.mainmenu <. lib.tempmenu
lib.mainmenu.3 = TMENU # just add 3d submenu. Prev menu haven't it
[global]

If not, please leave comment

thanks for your response. I solved in a different way and it works great. My solution:

3 = TMENU
3 {
    stdWrap.outerWrap = <div class="submenu-third-level"><ul class='submenu'>|</ul></div>
    stdWrap.if {
        value.data = field:pid
        isInList = {$menu.thirdSubmenuList}
    }

    NO.wrapItemAndSub = <li class="menu-item">|</li>

    ACT = 1
    ACT{
        wrapItemAndSub = <li class="menu-item active">|</li>
    }

    SPC = 1
    SPC {
       doNotLinkIt = 1
       doNotShowLink = 1
       allWrap = </ul><ul class='submenu'>
    }
}

The condition decide, if the menu will be displayed or not.

best regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM