我想根据客户端分辨率隐藏/显示菜单项。我认为最简单的方法是添加一个css类并使用媒体查询处理它。
所以我需要在带有typoscript的特定菜单项中添加一个类。 有没有办法做到这一点?
以下是我的typoscript菜单的样子:
menu.navbar = HMENU
menu.navbar {
entryLevel = {$threeme.menu.navbar.entry}
excludeUidList = {$threeme.menu.navbar.excludeUidList}
1 = TMENU
1 {
expAll = 1
stdWrap.dataWrap = <ul class="nav navbar-nav colum-{register:count_menuItems}">|</ul>
NO {
htmlSpecialChars = 1
wrapItemAndSub = <li id="navbar{field:uid}" class="" >|</li> |*| <li id="navbar{field:uid}">|</li> |*| <li id="navbar{field:uid}" class="last">|</li>
wrapItemAndSub.insertData = 1
ATagTitle.field = description // subtitle
}
ACT = 1
ACT {
htmlSpecialChars = 1
wrapItemAndSub = <li id="navbar{field:uid}" class=" active">|</li> |*| <li id="navbar{field:uid}" class="active">|</li> |*| <li id="navbar{field:uid}" class="last active">|</li>
wrapItemAndSub.insertData = 1
ATagTitle.field = description // subtitle
}
IFSUB = 1
IFSUB {
ATagTitle.field = description // subtitle
wrapItemAndSub = <li id="navbar{field:uid}" class="dropdown first">|</li> |*| <li id="navbar{field:uid}" class="dropdown">|</li> |*| <li id="navbar{field:uid}" class="dropdown last">|</li>
wrapItemAndSub.insertData = 1
stdWrap.htmlSpecialChars = 1
ATagParams = class="dropdown-toggle" data-hover="dropdown" role="button" aria-haspopup="true" aria-expanded="false"
linkWrap = |<span class="caret"></span>
ATagBeforeWrap = 1
}
ACTIFSUB < .IFSUB
ACTIFSUB = 1
ACTIFSUB.wrapItemAndSub = <li id="navbar{field:uid}" class="dropdown first active">|</li> |*| <li id="navbar{field:uid}" class="dropdown active">|</li> |*| <li id="navbar{field:uid}" class="dropdown last active">|</li>
}
2 = TMENU
2 {
expAll = 1
wrap = <ul class="dropdown-menu">|</ul>
NO.htmlSpecialChars = 1
NO.wrapItemAndSub = |*| <li class="odd">|</li> || <li class="even">|</li> |*|
ACT = 1
ACT.htmlSpecialChars = 1
ACT.wrapItemAndSub = |*| <li class="odd active">|</li> || <li class="even active">|</li> |*|
}
3 = TMENU
3 {
expAll = 1
wrap = <ul class="dropdown-submenu">|</ul>
NO.htmlSpecialChars = 1
NO.wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
ACT = 1
ACT.htmlSpecialChars = 1
ACT.wrapItemAndSub = <li class="first active">|</li> |*| <li class="active">|</li> |*| <li class="active last">|</li>
}
4 = TMENU
4 {
wrap = <ul class="dropdown-submenu-1">|</ul>
NO.htmlSpecialChars = 1
NO.wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
ACT = 1
ACT.htmlSpecialChars = 1
ACT.wrapItemAndSub = <li class="first active">|</li> |*| <li class="active">|</li> |*| <li class="active last">|</li>
}
}
答案 0 :(得分:1)
如果你想定位一个特定的页面,使用uid是IMO最好的方法,因为它是单义的;所以你可以在任何地方添加一个使用{field:uid}
。
我已经看到你已经用它来设置一些id(<li id="navbar{field:uid}"...
)