織夢一級菜單被點擊欄目高亮調用方法:
{dede:channel typeid ='1' type ='son'currentstyle="<li class='on'><a href='~typelink~'>~typename~</a></li>"}
<li><a href='[field:typeurl/]'>[field:typename/]</a></li>
{/dede:channel}
*注:對當前欄目列表設置了class='on',可以通過css樣式為其設置背景圖片或顏色,從而達到欄目高亮的效果。
首頁判斷是否添加class 調用方法:
<li><a {dede:field name=typeid runphp="yes"}(@me=="")? @me=" class='on'":@me="";{/dede:field} href="{dede:global.cfg_basehost/}">網站首頁</a></li>
*注:首頁判斷是否添加class='on'屬性
織夢二級菜單被點擊欄目高亮調用方法:
第一步:因為織夢默認dede:channelartlist標簽是不支持currentstyle屬性的,所以接加下先修改channelartlist.lib.php
1:打開include\taglib\channelartlist.lib.php,找到$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);
2:替換成下所示代碼:
$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);
if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid'] ){
$pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'on';
}
else{
$pv->Fields['currentstyle'] = '';
}
第二步:前臺調用:
{dede:channelartlist typeid='top' currentstyle='on' }<li><aclass="{dede:field.currentstyle/}" href="{dede:field name='typelink'/}" >{dede:field name='typename'/}</a><ul>{dede:channel type='son' noself='yes'} <li><a href="[field:typelink/]" >[field:typename/]</a></li> {/dede:channel}</ul> </li>{/dede:channelartlist} |
*注:生成欄目,循環出的頂級欄目li會有一個class=“on”的屬性。頁面效果如圖所示: