currentstyle 织梦_dede currentstyle属性完美解决方案

问题一、dede让channelartlist标签支持currentstyle属性 完美解决

打开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'}

{dede:field name='typename'/}

。。。

{/dede:channelartlist}

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

-------------------------------------------------------------------------------------------------------------------------

也可以与arclist标签(详见:http://www.ifreew.com/a/ym/Dedecms/9191.html)相结合使用,

这样调用:

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

{dede:field name='typename'/}

{dede:arclist titlelen='42' row='10' currentstyle="

~typename~"}

[field:array runphp='yes']

if(@me['currentstyle']){

@me = @me['currentstyle'];

}else{

@me = "

{@me['title']}";

}

[/field:array]

{/dede:arclist}

{/dede:channelartlist}

问题二、织梦channel标签currentstyle样式无效不起作用

我们在用织梦系统制作网站时,经常会用到channel标签来调子栏目。但是,很多朋友会遇到这种情况在使用channel标签来调子栏目的时候,指定 “type=son typeid=x” 发现currentstyle无效。今天笔者就跟大家分享一下解决方法。

1、解决channel标签currentstyle样式无效不起作用的错误方法

代码如下:

{dede: type='son' typeid='12' currentstyle="

~typename~ "} [field:typename/]

{/dede:channel}

解决的办法:把typeid=‘12’改为channel=‘1’ (文章模型id),首页除外,其他页面不需要指定typeid=x,会自动判断当前位置。

解决方法如下:

{dede: type='son' channel='1' currentstyle="

~typename~ "} [field:typename/]

{/dede:channel}

笔者经测试这种调用方式currentstyle根本是无效的,简直是无稽之谈。

2、解决channel标签currentstyle样式无效不起作用的正确方法修改include/taglib/channel.lib.php

if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )

改成

if( ( $row['id']== $refObj->TypeLink->TypeInfos['id'] || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )

笔者经测试这种调用方式currentstyle有效,可以解决解决channel标签currentstyle样式无效不起作用的问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值