站长资源
中国站长网站

织梦给导航栏channelartlist添加currentstyle属性直接调用实现当前导航高亮

找到include/taglib/channelartlist.lib.php  大约93行找到如下代码:

$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'] = '';  
}

前台调用方式:

{dede:channelartlist typeid='top' currentstyle="active"}
<li class="navitem">
	<a class="{dede:field.currentstyle/}" href="{dede:field%20name='typeurl'/}" target="_self"> {dede:field name='typename'/}</a> 
</li>
{/dede:channelartlist}

这样只要是当前栏目就会自动添加active类,从而实现导航高亮显示

本文出处:来自互联网信息共享,请勿相信收费信息站长资源 » 织梦给导航栏channelartlist添加currentstyle属性直接调用实现当前导航高亮

评论 1

评论前必须登录!

 


    Warning: A non-numeric value encountered in /www/wwwroot/www.wangdahai.cn/wp-content/themes/dux/modules/mo_comments_list.php on line 63
  1. #-9

    这样的博客让人禁不住一天来几次!

    促美优品6年前 (2017-12-18)