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

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

WBOY
WBOYOriginal
2016-05-20 10:19:201189browse

在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
      class="faq_ul2"> 7 {dede:channel type='son' noself='yes' currentstyle=" 8
    • 9 >~typename~ 10
  • 11 "} 12
  • 13 --[field:typename/] 14
  • 15 {/dede:channel} 16 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("~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的样式发生变化 .
     
     

     

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn