日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ecshop根目录调用_ecshop列表页 调用二级分类教程

發布時間:2024/1/23 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ecshop根目录调用_ecshop列表页 调用二级分类教程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在category.php 最后添加以下函數

/*獲取頂級id*/

function get_parent($value,$id='')

{

if($value!=0)

{

$sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '$value'";

$res = $GLOBALS['db']->getOne($sql);

return get_parent($res,$value);

}

else

{

return $id;

}

}

/*提取二級分類*/

function get_categories($cat_id = 0)

{

if ($cat_id > 0)

{

$parent_id = $cat_id;

}

else

{

$parent_id = 0;

}

/*

判斷當前分類中全是是否是底級分類,

如果是取出底級分類上級分類,

如果不是取當前分類及其下的子分類

*/

$sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$cat_id' AND is_show = 1 ";

if ($GLOBALS['db']->getOne($sql) || $parent_id == 0)

{

/* 獲取當前分類及其子分類 */

$sql = 'SELECT a.cat_id, a.cat_name, a.sort_order AS parent_order, a.cat_id, a.is_show,' .

'b.cat_id AS child_id, b.cat_name AS child_name, b.sort_order AS child_order ' .

'FROM ' . $GLOBALS['ecs']->table('category') . ' AS a ' .

'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS b ON b.parent_id = a.cat_id AND b.is_show = 1 ' .

"WHERE a.parent_id = '$parent_id' ORDER BY parent_order ASC, a.cat_id ASC, child_order ASC";

}

else

{

/* 獲取當前分類及其父分類 */

$sql = 'SELECT a.cat_id, a.cat_name, b.cat_id AS child_id, b.cat_name AS child_name, b.sort_order, b.is_show ' .

'FROM ' . $GLOBALS['ecs']->table('category') . ' AS a ' .

'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS b ON b.parent_id = a.cat_id AND b.is_show = 1 ' .

"WHERE b.parent_id = '$parent_id' ORDER BY sort_order ASC";

}

$res = $GLOBALS['db']->getAll($sql);

$cat_arr = array();

foreach ($res AS $row)

{

if ($row['is_show'])

{

$cat_arr[$row['cat_id']]['id'] ? = $row['cat_id'];

$cat_arr[$row['cat_id']]['name'] = $row['cat_name'];

$cat_arr[$row['cat_id']]['url'] ?= build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);

if ($row['child_id'] != NULL)

{

$cat_arr[$row['cat_id']]['children'][$row['child_id']]['id'] ? = $row['child_id'];

$cat_arr[$row['cat_id']]['children'][$row['child_id']]['name'] = $row['child_name'];

$cat_arr[$row['cat_id']]['children'][$row['child_id']]['url'] ?= build_uri('category', array('cid' => $row['child_id']), $row['child_name']);

}

}

}

return $cat_arr;

}

總結

以上是生活随笔為你收集整理的ecshop根目录调用_ecshop列表页 调用二级分类教程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。