dede列表頁調用二三級導航欄
1.首先看一下調用的代碼如下:
{dede:channelartlist typeid='3'}
{dede:fieldname='typename'/}
{dede:channel type='son'noself='yes'}
{/dede:channel}
{/dede:channelartlist}
這段代碼的意思是查詢欄目id為3的子欄目然后在查詢子欄目的子欄目。效果如圖所示:
這樣會出現一個問題,就是如果該欄目沒有子欄目的話,就會取他的同級欄目,那么如何解決{dede:channeltype='son'}無子欄目時取同級欄目問題呢?
其實很簡單:
打開:include/taglib/channel.lib.php文件。
找到
if($type=='son' && $reid!=0&& $totalRow==0)
改成
if($type=='son' && $reid!=0&& $totalRow==0&& $noself=='')
這樣就對了。
dede讓channelartlist標簽支持currentstyle屬性
打開include/taglib/channelartlist.lib.php
找到
$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);
在此行代碼下方增加以下代碼:
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'] = '';
}
網上找到的一般沒有加$typeids[$i]['id'] ==$refObj->TypeLink->TypeInfos['topid']
添加這個后才能對二級欄目也起作用
調用方法:
{dede:channelartlist typeid='2' currentstyle='current'}
- {dede:field name='typename'/}
-
。。。
{/dede:channelartlist}
如果是當前欄目則 li的class屬性顯示current,否則顯示class='' ,也可以修改currentstyle='這里改為你需要的類名'。
---------------------
作者:林家阿酒
來源:CSDN
原文:https://blog.csdn.net/wzl505/article/details/79104427
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!