zoukankan      html  css  js  c++  java
  • DedeCMS让channelartlist支持currentstyle属性

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

    打开include aglibchannelartlist.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'} <li class='{dede:field.currentstyle/}'> <a href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a> </li> {/dede:channelartlist}

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

    导航用channelartlist调用子栏目方法

    <div class="nav"> <li {dede:field name=typeid runphp="yes"}(@me=="")? @me=" class='navOn'":@me="";{/dede:field}> <a href='{dede:global.cfg_basehost/}'>首页</a> </li> <!-- 首页判断是否添加class --> {dede:channelartlist typeid='top' currentstyle='navOn'} <li class='{dede:field.currentstyle/}'> <a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a> <ul> {dede:channel type='son' noself='yes'} <li><a href="[field:typelink/]">[field:typename/]</a></li> {/dede:channel} </ul> </li> {/dede:channelartlist} </div>

           循环调用出的栏目<li>会有一个class=“navOn”属性。

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

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

    include aglibchannelartlist.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';

    后台调用部分修改为:

    <div class="nav"> <li {dede:field name=typeid runphp="yes"}(@me=="")? @me=" class='navOn'":@me="";{/dede:field}> <a href='{dede:global.cfg_basehost/}'>首页</a> </li> <!-- 当前栏目输出<li class='nLi on'>,非当前栏目输出<li class='nLi'> --> {dede:channelartlist typeid='top' currentstyle='nLi on'} <li class='{dede:field.currentstyle/}'> <a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a> <ul> {dede:channel type='son' noself='yes'} <li><a href="[field:typelink/]">[field:typename/]</a></li> {/dede:channel} </ul> </li> {/dede:channelartlist} </div>

     

    AiteCms,企业模板快速建站专家,点击了解更多

    转载自织梦模板教程(www.dede58.com

  • 相关阅读:
    Working with WordprocessingML documents (Open XML SDK)
    How to Choose the Best Way to Pass Multiple Models in ASP.NET MVC
    Azure:Manage anonymous read access to containers and blobs
    Convert HTML to PDF with New Plugin
    location.replace() keeps the history under control
    On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API
    HTTP Modules versus ASP.NET MVC Action Filters
    解读ASP.NET 5 & MVC6系列(6):Middleware详解
    Content Negotiation in ASP.NET Web API
    Action Results in Web API 2
  • 原文地址:https://www.cnblogs.com/dede58/p/7120078.html
Copyright © 2011-2022 走看看