注册 登录 欢迎您到模板精:织梦模板_dede模板_免费网站模板_网站源码下载

织梦教程_免费织梦模板下载_dede模板

该栏目分享织梦建站的基础知识,从织梦CMS的安装,到织梦标签的常规调用,以及织梦的常见问题答疑都有涉及。

当前位置:首页 > 织梦教程 >

织梦DedeCMS栏目列表调用中currentstyle中也支持autoindex的方法

免费网站模板 2020-09-16 10:58 织梦教程 评论
而我们在DedeCMS建站过程中,调用顶级栏目之类的会用到currentstyle属性,来实现当前栏目的高亮显示,而如果栏目列表的样式名呈递增的时候,就不能直接在currentstyle中加autoindex或itemindex了,这个时候需要我们修改下底层文件来实现,具体方法如下:
 
一、打开include/taglib/channel.lib.php中搜索(大概在第140行):
 
 
$linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
 
二、在下方加入代码:
 
 
$linkOkstr = str_replace("~autoindex~",$GLOBALS['autoindex']+1,$linkOkstr);
 
DedeCMS栏目列表调用中currentstyle中也支持autoindex的方法
 
修改前
 
DedeCMS栏目列表调用中currentstyle中也支持autoindex的方法
 
修改后
 
释义:这里是加一递增,如果是其他递增形式,改对应数字即可。
 
三、调用方法:
 
 
{dede:channel type='top' row='8' currentstyle="<li class='on'><a class='box~autoindex~' href='~typelink~'>~typename~</a></li>"}
<li><a class='box[field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global]' href='[field:typelink/]'>[field:typename/]</a></li>
{/dede:channel}