在制作DEDE企業(yè)模板的時(shí)候經(jīng)常會(huì)碰到導(dǎo)航要帶下拉菜單功能的!要使用下拉菜單就必須用到channelartlist標(biāo)簽,那要怎么才能讓channelartlist標(biāo)簽當(dāng)前欄目高亮呢?
熟悉dede的朋友都知道channel標(biāo)簽的高亮功能dede自帶的。
演示代碼:
{dede:channel type='top' row='10' currentstyle="<li class='hover'><a href='~typelink~' ~rel~><span>~typename~</span></a></li>"}
<li><a href='[field:typeurl/]' [field:rel/]><span>[field:typename/]</span></a></li>
說(shuō)明:當(dāng)前欄目高亮的樣式是:class='hover'
下面我就跟大家分享下channelartlist標(biāo)簽支持當(dāng)前欄目高亮方法:
打開(kāi)include/taglib/channelartlist.lib.php
找到
$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);
在此行代碼下方增加以下代碼:
// 讓channelartlist支持欄目高亮 Added By dede58 2011/1/19
if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id']){
$pv->Fields['currentstyle'] = ' class="hover"';
}
else{
$pv->Fields['currentstyle'] = '';
}
然后在模板文件中調(diào)用{dede:field name='currentstyle'/}即可,此字段輸出的內(nèi)容就是上面$pv->Fields['currentstyle'] = ' class="hover'"';中的 class="hover'"。