织梦dedecms让channelartlist标签里的channel支持currentstyle当前栏目高亮

织梦dedecms让channelartlist标签里的channel支持currentstyle当前栏目高亮

打开 /include/taglib/channelartlist.lib.php 找到

$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);

大约在93行,在它下面添加

if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['reid'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid'] || $typeids[$i]['id'] == GetTopid($refObj->TypeLink->TypeInfos['id']) )
{
	$pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'current';
}
else
{
	$pv->Fields['currentstyle'] = '';
}

 

织梦标签channelartlist默认是不支持多层嵌套后使用currentstyle高亮,修改一个文件可以实现,模板里调用代码:里面的hover就是你的高亮样式,

<div class="nav">
    <ul>
        {dede:channelartlist row=7 typeid=top currentstyle=hover}
        <li class="{dede:field.currentstyle/}">
            <a href="{dede:field.typeurl/}">{dede:field.typename/}</a>
            <ul>
                {dede:channel type='son' noself='yes' row='10' currentstyle="<li class='hover'><a href='~typelink~'>~typename~</a></li>"}
                <li><a href="[field:typeurl/]">[field:typename/]</a></li>
                {/dede:channel}
            </ul>
        </li>
        {/dede:channelartlist}
    </ul>
</div>

 

打开 \include\taglib\channel.lib.php

搜索

global $dsql;

修改成:

global $dsql,$_sys_globals;

继续搜索

$row['id']==$typeid

修改成:

$row['id']==$typeid || $row['id']==$_sys_globals['typeid']

 

 

 

 

 

THE END