织梦dedecms如何使用channelartlist标签显示当前文章高亮

晨曦的阳光淌进窗户,给你送出我的祝福,打开手机查看,温馨,一点点爬上你的笑脸,你是快乐的,我就是幸福的,早安!

在织梦系统中的artlist有时候需要当前文章高亮,或者和channelartlist标签套用实现当前栏目高亮和当前文章高亮,就可以通过此方法实现:

首先实现artlist当前文章高亮:

打开include\taglib\arclist.lib.php

$channelid = $ctag->GetAtt('channelid');

下增加:

$currentstyle = $ctag->GetAtt('currentstyle');

$tagid,$pagesize,$isweight

后增加

,$currentstyle

$noflag='',$tagid='', $pagesize=0, $isweight='N'

后增加

,$currentstyle=''

$row['textlink'] = "<a rel="nofollow noopener noreferrer" href='".$row['filename']."'>".$row['title']."</a>";

下增加

if($currentstyle && $row['id']==$arcid){

$currentstyle = str_replace('~typelink~', $row['filename'], $currentstyle);

$row['currentstyle'] = str_replace('~typename~', $row['title'], $currentstyle);

}

模板调用:

{dede:arclist titlelen='42' row='10' currentstyle="<li class='current' ><a rel="nofollow noopener noreferrer" href='~typelink~'>~typename~</a></li>"}
     [field:array runphp='yes']
         if(@me['currentstyle']){
             @me = @me['currentstyle'];
         }else{
             @me = "<li class='abc' ><a rel="nofollow noopener noreferrer" href='{@me['arcurl']}'>{@me['title']}</a></li>";
         }
     [/field:array]
{/dede:arclist}

如果和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['topid'] ){

$pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'current';

}

else{

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

}

网上找到的一般没有加$typeids[$i]['id'] ==$refObj->TypeLink->TypeInfos['topid']

添加这个后才能对二级栏目也起作用

调用方法:

{dede:channelartlist typeid='2' currentstyle='current'}

<li class='{dede:field.currentstyle/}'><a rel="nofollow noopener noreferrer" href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a></li>

{/dede:channelartlist}

如果是当前栏目则 li的class属性显示current,否则显示class='' ,也可以修改currentstyle='这里改为你需要的类名'。

这样调用:

{dede:channelartlist typeid='2' currentstyle='current'}

<dt ><a class='{dede:field.currentstyle/}' rel="nofollow noopener noreferrer" href='{dede:fieldname='typeurl'/}'>{dede:field name='typename'/}</a></dt>

{dede:arclist titlelen='42' row='10' currentstyle="<dd><a class='current' rel="nofollow noopener noreferrer" href='~typelink~'>~typename~</a></dd>"}

     [field:array runphp='yes']

         if(@me['currentstyle']){

             @me = @me['currentstyle'];

         }else{

             @me = "<dd ><a rel="nofollow noopener noreferrer" href='{@me['arcurl']}'>{@me['title']}</a></dd>";

         }

     [/field:array]

{/dede:arclist}

{/dede:channelartlist}

以上就是织梦dedecms如何使用channelartlist标签显示当前文章高亮。其实我是想鼓起勇气告诉你,如果有一天你想结婚了,告诉我。我会毫不顾忌的跟你走,不在乎你说的什么奢求不奢求。哪怕你没有房,我们可以租,只要有你在我就觉得有安全感。没有车,我就上班挤公交。钱是可以挣的,而对的人,错过了,就再也没有了。而只要你开口,说你要娶我,我就铁了心的嫁。更多关于织梦dedecms如何使用channelartlist标签显示当前文章高亮请关注haodaima.com其它相关文章!

您可能有感兴趣的文章
织梦后台文档列表添加复制文档功能支持所有模型

织梦无法上传ico图标格式文件的如何解决方法

dedecms如何实现任意页面调用当前会员信息的方

织梦dede:tag调用指定多个栏目的TAG标签

织梦栏目列表按附加表自定义字段排序