function renderCategory($id_category, $id_lang, $color = 'black') { $template = $this->template; $template->color_home = $color; $tmp = CategoryModel::getParents($id_category, $id_lang); $tmp = array_reverse($tmp); $tree = CategoryModel::getTree($id_lang); $template->parents = array(); foreach ($tmp as $t) { $template->parents[] = $tree[$t]; } $template->setFile(dirname(__FILE__) . '/eshop_category.latte'); $template->render(); }
public function renderSitemap() { $this->template->categories = CategoryModel::getTree($this->id_lang); $this->template->pages = $this->getService('Page')->getFluent()->where('visible = "0"')->fetchAll(); }
/* 商品页 */ define('ACC', true); require '../system/init.php'; $cateObj = new CategoryModel(); $goodsObj = new GoodsModel(); $goodsID = $_GET['goods_id']; $goodsInfo = $goodsObj->find($goodsID); if (!isset($goodsInfo)) { header('Location: index.php'); } //print_r(serialize($goodsInfo)); $catID = $goodsInfo['cat_id']; $allCates = $cateObj->select(); $cateNav = $cateObj->getTree($allCates, $catID); $cateInfo = $cateObj->find($catID); //print_r($cateNav); //加入浏览记录用cookie做 //是否有cookie,没有则设置,有则加入,超过5个自动删除 if (isset($_COOKIE['goods_history'])) { $history = _unserialize($_COOKIE['goods_history']); foreach ($history as $k => $v) { if ($v['goods_id'] != $goodsID) { continue; } else { array_splice($history, $k, 1); break; } } array_unshift($history, $goodsInfo);
//print_r($_POST); //第一步:后台检查数据 if (empty($_POST['cat_name'])) { exit('category name has to be set'); } //第二步:接受数据 $cat_id = $_POST['cat_id']; $data['cat_name'] = $_POST['cat_name']; $data['dscrpt'] = $_POST['cat_desc']; $data['parent_id'] = $_POST['parent_id'] + 0; /* 检查修改后的数据是否引起闭环 */ $cat = new CategoryModel(); $catlist = $cat->getList(); $trees = $cat->getTree($catlist, $data['parent_id']); //echo $cat_id."修改后上层栏目页是".$data['parent_id']."<br>"; $canupdate = true; foreach ($trees as $v) { if ($v['cat_id'] == $cat_id) { $canupdate = false; } } if (!$canupdate) { echo 'Error: Cannot update ' . $cat_id . '是' . $data['parent_id'] . '的祖先<br>'; exit; } if ($cat->update($cat_id, $data) != -1) { echo "category updated successfully"; } else { echo "category updated unsuccessfully";
public function renderSitemap() { $this->template->categories = CategoryModel::getTree(1); }