萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> CMS 教學

DedeCMS channel 標籤指定 typeid 後 currentstyle 失效的修復

問題描述

在模板中使用 {dede:channel typeid='1' currentstyle='...'} 指定欄目 ID 後,當前欄目高亮樣式 currentstyle 不生效。

修復方法

  1. 開啟 /include/taglib/channel.lib.php。
  2. 搜尋:
if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )
  1. 修改為:
if( ( $row['id']== $refObj->TypeLink->TypeInfos['id'] || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )

原理說明

  • 原代碼使用 $typeid 變數,但在指定 typeid 屬性時,該變數不一定等於當前欄目 ID。
  • $refObj->TypeLink->TypeInfos['id'] 為當前解析上下文的真實欄目 ID,可正確判斷是否為當前欄目。

修改後重新生成欄目頁,高亮樣式即可正常顯示。

copyright © 萬盛學電腦網 all rights reserved