• 技术文章 >php教程 >php手册

    dede channelartlist 中引用channel 并且设置当前选择类的样式,currentstyle暂时没有效果.特发求助!!!! - samcao

    2016-05-20 10:19:20原创537
    在dede中需要达到当前选择了该类,样式不同的话.如果是channelartlist 的话. 可以使用下面的情况:

    1 {dede:channelartlist typeid='6' row='3' currentstyle='current'}
    2     
  • class='{dede:field.currentstyle/}'> 3 4 {dede:field name='typename'/} 5 6
  • 7 {/dede:channelartlist}

    这个默认没有效果.需要在channelartlist.lib.php中做下面的步骤:

    在这行的下面添加

    1 $pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);
     1         ##########################################################
     2         
     3          if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid'] ){ 
     4             $pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'current'; 
     5         } 
     6         else{ 
     7             $pv->Fields['currentstyle'] = ''; 
     8         } 
     9         
    10         ###########################################################

    添加上面的代码才可以.

    如果只是使用channel的话. 可以使用下面来实现. 在此引用 "元曦" 的图. 也谢谢"元曦"的帮助.

    但是.如果两个套一起. 就实现不了.以下帖上我的代码.
     1 {dede:channelartlist typeid='6' row='3' currentstyle='current'}
     2     
  • class='{dede:field.currentstyle/}'> 3 4 {dede:field name='typename'/} 5 6 17
  • 18 {/dede:channelartlist}

    这样channelartlist 会有class的样式. 但是内部 channel 并不会有class="testclass" ,甚是不解。

    于是决定至底层的php文件中查看一下。在channel.lib.php中输出测试一下。

     1                 //处理同级栏目中,当前栏目的样式
     2                 if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )
     3                 {
     4                     print 'test_4';  //测试输出
     5                     $linkOkstr = $currentstyle;
     6                     $row['typelink'] = GetOneTypeUrlA($row);
     7                     $linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);
     8                     $linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);
     9                     $linkOkstr = str_replace("//m.sbmmt.com/m/article/~typelink~",$row['typelink'],$linkOkstr);
    10                     $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
    11                     $likeType .= $linkOkstr;
    12                 }
    13                 else
    14                 {
    15                     print 'test_5'; //测试输出
    16                     $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
    17                     if(is_array($dtp2->CTags))
    18                     {
    19                         foreach($dtp2->CTags as $tagid=>$ctag)
    20                         {
    21                             if(isset($row[$ctag->GetName()])) $dtp2->Assign($tagid,$row[$ctag->GetName()]);
    22                         }
    23                     }
    24                     $likeType .= $dtp2->GetResult();
    25                     
    26                 }

    看是输出的test_5. 不解. 暂做记录.也希望大家给上上课.

    不要单个效果的.已经实现 .或者小弟那里有理解不对的地方. 请指出.

    主要是需要

    11111111111111111

    1-2

    1-3

    22222222222222222
    2-1
    2-2
    如果上面有选择2-1的时候.2-1的样式发生变化 .

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:dede channelartlist 中引用channel 并且设置当前选择类的样式 currentstyle暂时没有
    上一篇:[麦先生]使用正则做一个简单的数据采集 - 麦先生 下一篇:PHP学习记录第一篇:Ubuntu14.04下LAMP环境的搭建 - dao_lee
    Web大前端开发直播班

    相关文章推荐

    • php判断当前用户已在别处登录的方法,当前用户在别处• PHP中PDO_MYSQL扩展安装的2种方法• php的数据数据类型• Codeigniter的一些优秀实践• 关于本地计算机无法启动Apache2,计算机启动Apache2
    1/1

    PHP中文网