DedeCMS让channelartlist支持currentstyle属性

织梦一二级导航菜单被点击顶级栏目高亮(加class)解决方法,DedeCMS让channelartlist支持currentstyle属性。

dedecms默认模板的channelartlist是不支持currentstyle属性的。currentstyle属性在导航中应用的比较多,可以实现循环调用栏目后,当前页<li>标签获得一个class="自定义命名"的属性,具体作用就不做说明了,需要修改文件。

打开include\taglib\channelartlist.lib.php

找到:

$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);

  在以上代码的下方添加如下代码:

//让channelarclist支持currentstyle属性 
if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid'] ){ $pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'nLi on'; } else{ $pv->Fields['currentstyle'] = 'nLi'; } 
//让channelarclist支持currentstyle属性end

调用代码如下:(给导航调用代码添加: currentstyle='current')

      {dede:channelartlist typeid='1,2,3,4,5,6,7' currentstyle='current'}
		<div class="nav-item-box maskLayer-relative">
			<div class="hover-box">
			    <a class="nav-item {dede:field.currentstyle/}" href="{dede:field name='typeurl'/}" title="{dede:field name='typename'/}">{dede:field name='typename'/}</a>
				<div class="nav-dropdown">
				    {dede:channel type='son' noself='yes' }
				    <a class="nav-dropdown-item only-oneline" href="[field:typelink/]" title="[field:typename/]">[field:typename/]</a>
				    {/dede:channel} 
				</div>
			</div>
		</div>
      {/dede:channelartlist}

效果如图:(会在样式里添加一个current,然后再在CSS给current添加样式)

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值