在给客户做网站的时候,有一个需求:点击产品二级子类的时候显示当前栏目的三级产品类目,同时二级栏目和三级栏目都加current高亮显示,效果如下图所示:

1、打开 \include\taglib\channelartlist.lib.php 找到
$tpsql = " reid='$typeid' AND ispart<>2 AND ishidden<>1 ";
改成
if($type=='son')
{
$typeid = ( !empty($refObj->TypeLink->TypeInfos['id']) ? GetTopid($refObj->TypeLink->TypeInfos['id']) : 0 );
$tpsql = " reid='$typeid' AND ishidden<>1 ";
}
else
{
$tpsql = " reid='$typeid' AND ispart<>2 AND ishidden<>1 ";
}2、打开 \include\taglib\channel.lib.php 找到
if($type=='son' && $reid!=0 && $totalRow==0)
改成
if($type=='son' && $reid!=0 && $totalRow==0 && $noself=='')
3、后台-系统-其它选项 去掉php

4、列表页和内容页 标签写法
<style type="text/css">
.subnav2{ display:none}
</style>
{dede:php}
$GLOBALS['thisid'] = intval($refObj->Fields['typeid']);
$GLOBALS['reid'] = intval($refObj->Fields['reid']);
$GLOBALS['topid'] = intval($refObj->Fields['topid']);
{/dede:php}
{dede:channelartlist type=son}
<li{dede:field.typeid runphp=yes}(@me==$GLOBALS['thisid']||@me==$GLOBALS['reid']||@me==$GLOBALS['topid'])? @me=' class="current"':@me='';{/dede:field.typeid}>
<a href='{dede:field.typeurl/}'>{dede:field.typename/}</a>
</li>
{/dede:channelartlist}
{dede:channelartlist type=son}
<div class="subnav2" style="{dede:field.typeid runphp=yes}(@me==$GLOBALS['thisid']||@me==$GLOBALS['reid']||@me==$GLOBALS['topid'])? @me=' display:block !important':@me='';{/dede:field.typeid}">
<ul>{dede:channel type=son noself=yes}
<a href='[field:typeurl/]'[field:id runphp=yes](@me==$GLOBALS['thisid'])? @me=' class="current"':@me='';[/field:id]>[field:typename/]</a>
{/dede:channel}</ul>
</div>
{/dede:channelartlist}思路是subnav2默认display为none,当前二级栏目的三级再display:block显示出来,同时各自定义current即可。
部分参考:blog.csdn.net/hlplan/article/details/77769647
