dede:channelartlist嵌套读取二级栏目并设置当前栏目高亮网上有不少的方法,鱼龙混杂大多不可用,道成最近正字做一个案例用到这个嵌套,顺便给大家分享一套完整的方案首先:修改PHP文件打开:include\taglib\channelartlist.lib.php搜索:$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]); 注意不要含有空格,否则搜索不到然后在下方添加代码:
方法/步骤
1
if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid'] ){ $pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'active'; } else{ $pv->Fields['currentstyle'] = ''; } 其中active为您需要用到的当前样式的css
2
本案例用到的类为active.topnav li a.active{background:url(../images/nav_bg.png) no-repeat center 0px; color:#fff;}
3
然后在调用的时候
- {dede:channelartlist row=6 typeid='top'}
- {dede:field name='typename'/}
- {dede:channel type='son' noself='true'}
- [field:typename/]| {/dede:channel}
{/dede:channelartlist}