修改include/taglib/channelartlist.lib.php文件
在$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);下面增加
//新增支持currentstyle属性
if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid'] ){
$pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'current';
}
else{
$pv->Fields['currentstyle'] = '';
}
判断typeid是否为空,如果为空,则当前打开的是首页,就给首页添加一个active的样式。
其它导航循环,只要给循环标签中添加一个currentstyle=‘active’,然后将currentstyle样式添加到当前循环的那个导航中.
<div class="nav">
<ul class="clearfix">
<li {dede:field name=typeid runphp="yes"}(@me=="")? @me=" class='active' ":@me="class=''";{/dede:field}>
<a href="/">网站首页</a>
</li>
{dede:channelartlist typeid='top' currentstyle='active'}
<li class="{dede:field.currentstyle/}" >
<a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a>
</li>
{/dede:channelartlist}
</ul>
</div>