/** * 取出指定栏目的商品 * @param $cat_id * @return array $sons */ public function getGoodsByCat($cat_id) { $category = new CatModel(); $cats = $category->getList(); $sons = $category->getListTree($cats, $cat_id); $sub = array($cat_id); if (!empty($sons)) { foreach ($sons as $v) { $sub[] = $v['cat_id']; } } $in = implode(',', $sub); $sql = 'select goods_id,goods_name,shop_price,market_price,thumb_img from ' . $this->table . ' where cat_id in (' . $in . ') order by add_time'; return $this->db->getAll($sql); }
<?php define('ACC', true); require '../include/init.php'; /*** * file catelist.php * 目录列表显示页面控制器 * @author zhangyang */ $cat = new CatModel(); $catelist = $cat->getList(); $catelist = $cat->getListTree($catelist, 0); include ROOT . 'view/admin/templates/catelist.html';
<?php define('ACC', true); require '../include/init.php'; /*** * file catedit.php * 栏目编辑页面控制器 * * 接收cat_id * 实例化model * 调用model取出栏目信息 * 展示到表单 * @author zhangyang */ $cat_id = $_GET['cat_id'] + 0; $cat = new CatModel(); $catinfo = $cat->find($cat_id); $catlist = $cat->getList(); $catlist = $cat->getListTree($catlist); //print_r($catinfo); include ROOT . 'view/admin/templates/catedit.html';