织梦Dedecms的channelartlist标签支持当前栏目高亮方法

 在制作DEDE企业模板的时候经常会碰到导航要带下拉菜单功能的!要使用下拉菜单就必须用到channelartlist标签,那要怎么才能让channelartlist标签当前栏目高亮呢?

        熟悉dede的朋友都知道channel标签的高亮功能dede自带的。

演示代码:

{dede:channel type='top' row='10' currentstyle="<li class='hover'><a href='~typelink~' ~rel~><span>~typename~</span></a></li>"}

<li><a href='[field:typeurl/]' [field:rel/]><span>[field:typename/]</span></a></li>

 说明:当前栏目高亮的样式是:class='hover'

下面我就跟大家分享下channelartlist标签支持当前栏目高亮方法:

 

打开include/taglib/channelartlist.lib.php

找到

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

在此行代码下方增加以下代码:

// 让channelartlist支持栏目高亮 Added By dede58  2011/1/19

if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id']){

$pv->Fields['currentstyle'] = ' class="hover"';

}

else{

$pv->Fields['currentstyle'] = '';

}

然后在模板文件中调用{dede:field name='currentstyle'/}即可,此字段输出的内容就是上面$pv->Fields['currentstyle'] = ' class="hover'"';中的 class="hover'"。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5017bcdafffbd45b51865e1d9b6809a6.html