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'}
<li class='{dede:field.currentstyle/}'><a href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a></li>
。。。
{/dede:channelartlist}
如果是当前栏目则 li的class属性显示current,否则显示class='' ,也可以修改currentstyle='这里改为你需要的类名'。
-------------------------------------------------------------------------------------------------------------------------
也可以与arclist标签(详见:http://www.ifreew.com/a/ym/Dedecms/9191.html)相结合使用,
这样调用:
{dede:channelartlist typeid='2' currentstyle='current'}
<dt ><a class='{dede:field.currentstyle/}' href='{dede:fieldname='typeurl'/}'>{dede:field name='typename'/}</a></dt>
{dede:arclist titlelen='42' row='10' currentstyle="<dd><a class='current' href='~typelink~'>~typename~</a></dd>"}
[field:array runphp='yes']
if(@me['currentstyle']){
@me = @me['currentstyle'];
}else{
@me = "<dd ><a href='{@me['arcurl']}'>{@me['title']}</a></dd>";
}
[/field:array]
{/dede:arclist}
{/dede:channelartlist}
问题二、织梦channel标签currentstyle样式无效不起作用
我们在用织梦系统制作网站时,经常会用到channel标签来调子栏目。但是,很多朋友会遇到这种情况在使用channel标签来调子栏目的时候,指定 “type=son typeid=x” 发现currentstyle无效。今天笔者就跟大家分享一下解决方法。
1、解决channel标签currentstyle样式无效不起作用的错误方法
代码如下:
{dede: type='son' typeid='12' currentstyle="<li><a href='~typelink~' title="~typename~">~typename~</a> </li>"}
<li><a title="[field:typename/]" href="[field:typelink/]">[field:typename/]</a></li>
{/dede:channel}
解决的办法:把typeid=‘12’改为channel=‘1’ (文章模型id),首页除外,其他页面不需要指定typeid=x,会自动判断当前位置。
解决方法如下:
{dede: type='son' channel='1' currentstyle="<li><a href='~typelink~' title="~typename~">~typename~</a> </li>"}
<li><a title="[field:typename/]" href="[field:typelink/]">[field:typename/]</a></li>
{/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样式无效不起作用的问题。
dede currentstyle属性完美解决方案的更多相关文章
- dede让channelartlist标签支持currentstyle属性 完美解决
打开include\taglib\channelartlist.lib.php 找到 $pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]); ...
- 让arclist标签也支持currentstyle属性 完美解决
1.查找到: $channelid = $ctag->GetAtt('channelid'); 在下面插入:$currentstyle = $ctag->GetAtt('currentst ...
- .NET领域最为流行的IOC框架之一Autofac WebAPI2使用Autofac实现IOC属性注入完美解决方案 AutoFac容器初步
.NET领域最为流行的IOC框架之一Autofac 一.前言 Autofac是.NET领域最为流行的IOC框架之一,微软的Orchad开源程序使用的就是Autofac,Nopcommerce开源程 ...
- 关于Entity Framework中的Attached报错的完美解决方案终极版
之前发表过一篇文章题为<关于Entity Framework中的Attached报错的完美解决方案>,那篇文章确实能解决单个实体在进行更新.删除时Attached的报错,注意我这里说的单个 ...
- Xcode6.1标准Framework静态库制作方法。工程转Framework,静态库加xib和图片。完美解决方案。
http://www.cocoachina.com/bbs/read.php?tid-282490.html Xcode6.1标准Framework静态库制作方法.工程转Framework,静态库加x ...
- WebBrowser脚本错误的完美解决方案
原文:WebBrowser脚本错误的完美解决方案 当IE浏览器遇到脚本错误时浏览器,左下角会出现一个黄色图标,点击可以查看脚本错误的详细信息,并不会有弹出的错误信息框.当我们使用WebBrowse ...
- DevExpress控件cxGrid实现多列模糊匹配输入的完美解决方案
本方案不需要修改控件源码,是完美解决cxgrid或TcxDBExtLookupComboBox支持多列模糊匹配快速输入的最佳方案!! 转自https://blog.csdn.net/qq5643020 ...
- asp.net2.0导出pdf文件完美解决方案【转载】
asp.net2.0导出pdf文件完美解决方案 作者:清清月儿 PDF简介:PDF(Portable Document Format)文件格式是Adobe公司开发的电子文件格式.这种文件格式与操作系统 ...
- DedeCMS让channelartlist支持currentstyle属性
dedecms默认模板的channelartlist是不支持currentstyle属性的.currentstyle属性在导航中应用的比较多,可以实现循环调用栏目后,当前页<li>标签获得 ...
随机推荐
- 【Python⑥】python的缩进,条件判断和循环
缩进 Python的最大特色是用缩进来标明成块的代码. 这点和其他语言区别很明显,比如大家熟悉的C语言里: ) { num+=; flag-=; } 而在python中: if flag>= 0 ...
- 过滤器Filter
实现Filter接口:
- PHPExcel读取Excel文件的实现代码
<?php require_once 'PHPExcel.php'; /**对excel里的日期进行格式转化*/ function GetData($val){ $jd = GregorianT ...
- Java中的弱引用
Strong references StringBuffer buffer = new StringBuffer(); 普通的对象创建都是这种类型,只要buffer还存在,对象就不会被GC回收.同时也 ...
- Haskell Tuple相关总结
一.相关操作 zip:将两个List合并成一个元组序对的List. fst:返回元组序对第一个元素. snd:返回元组序对第二个元素. PS:元组序对是元组中只有两个元素的元组. 二.与List的比较 ...
- 阅读摘录《javascript 高级程序设计》01
前言: 因为工作需要,所以开始主攻前台JS方面的技术.在以前的工作中,使用过这门脚本语言.但是都是比较凌乱的,用到什么学什么,只是为了实现业务,而去使用. 不会考虑到代码优化,封装对象等.今次特意借了 ...
- wordpress及其simple_press插件完成 的中文论坛
wordpress 及 其simple_press插件的论坛功能 开发准备: 一直从事java及as3方面的开发,首次听同事提起PHP的wordpress,于是上网查了下, 才知道这款软件的强大,转而 ...
- ThinkPHP模板中如何操作session,以及如果session中保存的是数组的情况
在ThinkPHP的模板中操作session时,可以参考ThinkPHP参考文档中的“模板—>系统变量”部分,在默认模板引擎中,语法如下: {$Think.session.user} //输出s ...
- 在CentOS6.8上面安装Python3.5
以前每次装Linux,升级Python,都会一堆问题,然后Google,本来想着记录一下,结果问题太多了,也就记不住了,这次特地记了下来. 在CentOS6.8上面安装Python3.5我的系统是Ce ...
- Two Sum (c#)
Given an array of integers, find two numbers such that they add up to a specific target number. The ...