搜索

dede织梦 点击文章列表标题切换标签效果 arclist标签完美支持currentstyle属性

2020-11-27 18:03| 发布者: happyxp| 查看: 1787| 评论: 0

摘要: dedecms织梦当中因为需要做一个效果,点击左侧标题,切换对应的页面,点击的标签页跟着切换,因为页面需要静态生成,所以最好在系统里面通过php代码实现。dede版本v5.7sp找到PHP修改:include/taglib/arclist.lib.php ...

dedecms织梦当中因为需要做一个效果,点击左侧标题,切换对应的页面,点击的标签页跟着切换,因为页面需要静态生成,所以最好在系统里面通过php代码实现。

dede版本v5.7sp

找到PHP修改:
include/taglib/arclist.lib.php

1.查找到: 
$channelid = $ctag->GetAtt('channelid');

在下面插入:
$currentstyle = $ctag->GetAtt('currentstyle');
2、查找:
return lib_arclistDone
           (
             $refObj, $ctag, $typeid, $ctag->GetAtt('row'), $ctag->GetAtt('col'), $titlelen, $infolen,
             $ctag->GetAtt('imgwidth'), $ctag->GetAtt('imgheight'), $listtype, $orderby,
             $ctag->GetAtt('keyword'), $innertext, $envs['aid'], $ctag->GetAtt('idlist'), $channelid,
             $ctag->GetAtt('limit'), $flag,$ctag->GetAtt('orderway'), $ctag->GetAtt('subday'), $ctag->GetAtt('noflag'),
             $tagid,$pagesize,$isweight
           );


替换为:
return lib_arclistDone
           (
             $refObj, $ctag, $typeid, $ctag->GetAtt('row'), $ctag->GetAtt('col'), $titlelen, $infolen,
             $ctag->GetAtt('imgwidth'), $ctag->GetAtt('imgheight'), $listtype, $orderby,
             $ctag->GetAtt('keyword'), $innertext, $envs['aid'], $ctag->GetAtt('idlist'), $channelid,
             $ctag->GetAtt('limit'), $flag,$ctag->GetAtt('orderway'), $ctag->GetAtt('subday'), $ctag->GetAtt('noflag'),
             $tagid,$pagesize,$isweight,$currentstyle
           );
其实就是在调用函数的最后加了一个$currentstyle实参
3、查找
function lib_arclistDone(&$refObj, &$ctag, $typeid=0, $row=10, $col=1, $titlelen=30, $infolen=160,
        $imgwidth=120, $imgheight=90, $listtype='all', $orderby='default', $keyword='',
        $innertext='', $arcid=0, $idlist='', $channelid=0, $limit='', $att='', $order='desc', $subday=0, $noflag='',$tagid='', $pagesize=0, $isweight='N')
替换为:
function lib_arclistDone(&$refObj, &$ctag, $typeid=0, $row=10, $col=1, $titlelen=30, $infolen=160,
        $imgwidth=120, $imgheight=90, $listtype='all', $orderby='default', $keyword='',
       $innertext='', $arcid=0, $idlist='', $channelid=0, $limit='', $att='',$order='desc', $subday=0, $noflag='',$tagid='', $pagesize=0,$isweight='N',$currentstyle='')
其实就是在函数后面加了一个$currentstyle=''形参
4、查找
$row['textlink'] = "<a 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 href='~typelink~'>~typename~</a></li>"}
     [field:array runphp='yes']
         if(@me['currentstyle']){
             @me = @me['currentstyle'];
         }else{
             @me = "<li class='current' ><a href='{@me['arcurl']}'>{@me['title']}</a></li>";
         }
     [/field:array]
{/dede:arclist}

方法二:

{dede:arclist titlelen='26' row='10' currentstyle='1'}
[field:array runphp='yes']
if(@me['currentstyle']){
@me = "<a href='{@me["arcurl"]}’ title='{@me["title"]}' class='current'>{@me["title"]}</a>";
}else{
@me = "<a href='{@me["arcurl"]}' title='{@me["title"]};class=''>{@me["title"]}</a>";
}
[/field:array]
{/dede:arclist}

两种都可以,看方便使用。


也可以与channelartlist标签(详见:http://bbs.dedecms.com/read.php?tid-559891-ds-1.html )相结合使用,
这样调用:

{dede:arclist titlelen='42' row='10' currentstyle="<li class='current'><a href='~typelink~' >~typename~</a></li>"}
     [field:array runphp='yes']
         if(@me['currentstyle']){
             @me = @me['currentstyle'];
         }else{
             @me = "<li><a href='{@me['arcurl']}'>{@me['title']}</a></li>";
         }
     [/field:array]
{/dede:arclist}
@me = "<li><a href='{@me['arcurl']}'>{@me['title']}</a></li>";这一行不加任何样式标签

以上是网上解决dede织梦 点击文章列表标题切换标签效果 arclist标签完美支持currentstyle属性的方案,经过测试可以实现需要的效果。这个方案存在“”和‘’英文和中文状态的混乱,使用的时候要替换下即可。


路过

雷人

握手

鲜花

鸡蛋
本站文章如无特殊说明均为 虾皮社区 原创,可无偿使用和传播,欢迎转载分享!
转载请注明本文地址:
如有文章侵犯了您的权利,请联系本站站长,我们将在第一时间删除相关内容,谢谢!

虾皮社区,成立十年了!

站长自己也搞不懂想做个什么,反正就是一直在努力的做!

Copyright © 2007-2024 xp6.org Powered by Discuz

QQ|Archiver|手机版|小黑屋|虾皮社区 |网站地图
返回顶部