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

在dede中需要达到当前选择了该类,样式不同的话.如果是channelartlist 的话. 可以使用下面的情况:

1 {dede:channelartlist typeid='6' row='3' currentstyle='current'}
2     <li class='{dede:field.currentstyle/}'>
3         <a href='{dede:field name='typeurl'/}'>
4             {dede:field name='typename'/}
5         </a>
6     </li>
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     <li class='{dede:field.currentstyle/}'>
 3         <a href='{dede:field name='typeurl'/}'>
 4             {dede:field name='typename'/}
 5         </a>
 6         <ul class="faq_ul2">
 7             {dede:channel type='son' noself='yes' currentstyle="
 8                 <li class='testclass'>
 9                     <a href='~typelink~' title="~typename~">~typename~</a>
10                 </li>
11             "}
12                 <li>
13                     <a title="[field:typename/]" href="[field:typelink/]">--[field:typename/]</a>
14                 </li>
15              {/dede:channel}
16         </ul>
17     </li>
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的样式发生变化 .
 
 
原文地址:https://www.cnblogs.com/drgcaosheng/p/5445880.html