我有一个看起来像这样的菜单
if (ContextCompat.checkSelfPermission(CreatePlayerActivity.this,
Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(CreatePlayerActivity.this,
Manifest.permission.READ_EXTERNAL_STORAGE)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(CreatePlayerActivity.this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
换句话说,我有时有两个级别的导航,有时三个。我需要检查菜单点是否有三个或两个级别,并且需要相应地更改第一级的atagparams。
-AAA
-SUB_A1
-SUB_A2
-SUB_A3
-BBB
-SUB_B1
-SUB_B1_1
-SUB_B1_2
-SUB_B2
-SUB_B2_1
-SUB_B2_2
所以我需要改变
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"
如果级别3可用。是否有可能或者我是否需要解决这个问题?
KR 阿迪
答案 0 :(得分:0)
使用扩展VHS的有用提示我现在仅使用流体查看器创建导航。该解决方案目前适用于我。主要部分是循环遍历项目并将变量设置为“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>