织梦DEDECMS模板里调用二级栏目标签并使channelartlist支持currentstyle

{dede:channelartlist typeid='top' row='7'}
            <li class="{dede:field.currentstyle/}">
                <a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a>
                <ul class='sub_menu'>
                    {dede:channel type='son' noself='yes'}
                    <li><a href="[field:typelink/]">[field:typename/]</a></li>
                    {/dede:channel}
                    <li class='bottom'></li>
                </ul>
            </li>
{/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'] = 'active';  
        }  
        else{  
            $pv->Fields['currentstyle'] = '';  
        } 

 网上找到的一般没有加$typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid'] 

添加这个后才能对二级栏目也起作用

你可能感兴趣的:(织梦DEDECMS模板里调用二级栏目标签并使channelartlist支持currentstyle)