1. 程式人生 > >destoon6.0獲取當前分類和子類

destoon6.0獲取當前分類和子類

子類 是否 輸出 return from category intval where 分類信息

頁面上的$CAT 和 怎麽獲得當前分類的名稱 跟 子類

$CAT 在根目錄下的 commen.inc.php定義賦值 if($catid) $CAT = get_cat($catid); // 如果有catid參數傳來 則讀取當前分類信息

函數 get_cat 在 include/global.func.php 定義

function get_cat($catid) { //獲取指定分類的分類屬性,符合條件返回所有字段

global $db;

$catid = intval($catid);

return $catid ? $db->get_one("SELECT * FROM {$db->pre}category WHERE catid=$catid") : array();

}

所有 可以直接用$CAT[‘catname‘];輸出當前分類名稱。

返回的字段中 有個字段arrchildid 存儲了所有子類id和本身id 例如1分類的子類是3,7,20,那麽 arrchildid 就是1,3,7,20 獲取當前分類的產品時直接

字段 child 標誌是否有子類

$condition .= ($CAT[‘child‘]) ? " AND catid IN (".$CAT[‘arrchildid‘].")" : " AND catid=$catid"; //有子類就取當前類和所有子類的產品 沒有就取當前分類的產品。

樣例:http://zhimo.yuanzhumuban.cc/

destoon6.0獲取當前分類和子類