栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > php开源框架 > dedecms

DedeCMS让channelartlist支持currentstyle属性

dedecms 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

DedeCMS让channelartlist支持currentstyle属性

    dedecms默认模板的channelartlist是不支持currentstyle属性的。currentstyle属性在导航中应用的比较多,可以实现循环调用栏目后,当前页

  • 标签获得一个class="自定义命名"的属性,具体作用就不做说明了,需要修改文件。

    打开includetaglibchannelartlist.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

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

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

    调用方法:
    {dede:channelartlist typeid='2' currentstyle='current'}  
     
  • {dede:field name='typename'/}
  • {/dede:channelartlist}

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

    导航用channelartlist调用子栏目方法
    
     
  • 首页
  • {dede:channelartlist typeid='top' currentstyle='navOn'}
  • {dede:field name='typename'/}
      {dede:channel type='son' noself='yes'}
    • [field:typename/]
    • {/dede:channel}
  • {/dede:channelartlist}

           循环调用出的栏目

  • 会有一个class=“navOn”属性。

    配合使用 SuperSlide可以构建美观的下拉菜单功能

          具体的方法可以参考官方的使用方法,我使用的时候发现,“手动或后台程序添加titOnClassName类名(默认是'on'),相当于设置参数defaultIndex:2。若同时设置参数returnDefault:true,则鼠标移走后返回当前频道。 ”这个功能失效,更新后才能正常使用,但是一定要按照以上步骤进行修改才能让channelartlist支持currentstyle属性。下面附修改方法:

    includetaglibchannelartlist.lib.php部分修改为

    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';  

    后台调用部分修改为:

    
     
  • 首页
  • {dede:channelartlist typeid='top' currentstyle='nLi on'}
  • {dede:field name='typename'/}
      {dede:channel type='son' noself='yes'}
    • [field:typename/]
    • {/dede:channel}
  • {/dede:channelartlist}

  • 转载请注明:文章转载自 www.mshxw.com
    本文地址:https://www.mshxw.com/it/9053.html
    我们一直用心在做
    关于我们 文章归档 网站地图 联系我们

    版权所有 (c)2021-2022 MSHXW.COM

    ICP备案号:晋ICP备2021003244-6号