1. 程式人生 > 實用技巧 >織夢channelartlist高亮並且讓巢狀標籤裡的channel也支援currentstyle高亮

織夢channelartlist高亮並且讓巢狀標籤裡的channel也支援currentstyle高亮

dede:channelartlist欄目高亮實現教程

開啟 /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['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'] = '';
}

然後 dede:channelartlist 標籤裡是高亮標籤呼叫是

{dede:field.currentstyle/}

例如下面的寫法

巢狀標籤

<div class="nav">
    <ul>
        {dede:channelartlist row=7 typeid=top currentstyle=current}
        <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>

channelartlist巢狀channel標籤也高亮實現教程

開啟 /include/taglib/channel.lib.php 找到

global $dsql;

改成

global $dsql,$_sys_globals;

繼續找到

$row['id']==$typeid

改成

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