在給客戶做網(wǎng)站的時候,有一個需求:點擊產(chǎn)品二級子類的時候顯示當前欄目的三級產(chǎn)品類目,同時二級欄目和三級欄目都加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、后臺-系統(tǒng)-其它選項 去掉php
4、列表頁和內(nèi)容頁 標簽寫法
<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