如果存在 3 级菜单,Typoscript 会更改标签参数

Typoscript change a tag params if level 3 menu exists

我有一个看起来像这样的菜单

-AAA
  -SUB_A1
  -SUB_A2
  -SUB_A3
-BBB
  -SUB_B1
     -SUB_B1_1
     -SUB_B1_2
  -SUB_B2
     -SUB_B2_1
     -SUB_B2_2

换句话说,我有时有两级导航,有时有三级。我需要检查菜单点是否有三级或两级,并需要相应地更改第一级的atagparams。

1 = TMENU
1 {
    wrap =  <ul class="menu sitemenu-submenu-light sitemenu-extra-strong sitemenu-extra-no-arrows">|</ul>

    expAll = 1
    noBlur = 1
    NO = 1
    NO {
        wrapItemAndSub = <li class="mega-menu">|</li>
        stdWrap.htmlSpecialChars = 1
        #ATagParams ="topmenu-item text-hover-blue"
        ATagParams = class="menu-item menu-separator"
    }
    ACT < .NO
    ACT = 1
    ACT{
        wrapItemAndSub = <li class="current mega-menu">|</li>
   }
}

所以我需要改变

ATagParams ="topmenu-item text-hover-blue"

ATagParams = class="menu-item menu-separator"

如果 3 级可用。有可能还是我需要解决这个问题?

韩国 阿迪

有了使用扩展 VHS 的有用提示,我现在仅使用流畅的 viewhelpers 创建了导航。该解决方案目前对我有用。主要部分是循环遍历项目并将变量设置为 "hasSubs",然后检查它是真还是假

    {namespace v=FluidTYPO3\Vhs\ViewHelpers}
<v:page.menu>
    <div class="abc-menu sitemenu-submenu-light sitemenu-extra-strong sitemenu-extra-no-arrows">
        <f:for each="{menu}" as="item">
            <v:variable.set name="hasSub" value="0" />
            <f:if condition="{item.hasSubPages}">
                <v:page.menu pageUid="{item.uid}">
                         <span style="display: none">
                These aren't the droids you are looking for</span>
                    <f:for each="{menu}" as="subItemCheck">
                        <f:if condition="{subItemCheck.hasSubPages}">
                            <f:then>
                                <v:variable.set name="hasSub" value="1" />
                            </f:then>
                        </f:if>
                    </f:for>
                </v:page.menu>
            </f:if>

            <f:if condition="{hasSub} == 1">
                <f:then>
                    <li class="mega-menu">
                </f:then>
                <f:else>
                    <li>
                </f:else>
            </f:if>

            <f:link.page pageUid="{item.uid}" class="menu-item menu-separator">{item.linktext}</f:link.page>
            <f:if condition="{item.hasSubPages}">
                <v:page.menu pageUid="{item.uid}">
                    <f:if condition="{hasSub} == 1">
                        <f:then>
                            <div class="abc-mega" data-columns="5">
                        </f:then>
                        <f:else>
                            <ul>
                        </f:else>
                    </f:if>
                    <f:for each="{menu}" as="subItem">
                        <f:if condition="{subItem.hasSubPages}">
                            <f:then>
                                <v:page.menu pageUid="{subItem.uid}">
                                    <v:variable.set name="menuHasThreeSubs" value="1" />
                                    <div class="abc-mega-section">
                                        <h4 data-role="title">
                                            <f:link.page pageUid="{subItem.uid}" class="menu-item">{subItem.linktext}</f:link.page>
                                        </h4>
                                        <ul>
                                            <f:for each="{menu}" as="subSubItem">
                                                <li>
                                                    <f:link.page pageUid="{subSubItem.uid}" class="menu-item">{subSubItem.linktext}</f:link.page>
                                                </li>
                                            </f:for>
                                        </ul>
                                    </div>
                                </v:page.menu>
                            </f:then>
                            <f:else>
                                <f:if condition="{hasSub} == 1">
                                    <f:then>
                                        <div class="abc-mega-section">
                                            <h4 data-role="title">
                                                <f:link.page pageUid="{subItem.uid}" class="menu-item">{subItem.linktext}</f:link.page>
                                            </h4>
                                        </div>
                                    </f:then>
                                    <f:else>
                                        <li>
                                            <f:link.page pageUid="{subItem.uid}" class="menu-item">{subItem.linktext}</f:link.page>
                                        </li>
                                    </f:else>
                                </f:if>
                            </f:else>
                        </f:if>
                    </f:for>
                    <f:if condition="{hasSub} == 1">
                        <f:then>
                            </div>
                        </f:then>
                        <f:else>
                             </ul>
                    </f:else>
                    </f:if>
                </v:page.menu>
            </f:if>
    </f:for>
</div>
</v:page.menu>