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的樣式發生變化 .
 
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM