示例#1
0
 public function catGoodsCount($cat_id)
 {
     $category = new CatModel();
     $cats = $category->select();
     // 取出所有的栏目来
     $sons = $category->getCatTree($cats, $cat_id);
     // 取出给定栏目的子孙栏目
     $sub = array($cat_id);
     if (!empty($sons)) {
         // 没有子孙栏目
         foreach ($sons as $v) {
             $sub[] = $v['cat_id'];
         }
     }
     $in = implode(',', $sub);
     $sql = 'select count(*) from goods where cat_id in (' . $in . ')';
     return $this->db->getOne($sql);
 }
示例#2
0
	public function catGoods($cat_id){
		$category = new CatModel();
		$cats = $category->select(); //取出所有的栏目来
		$sons = $category->getCatTree($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 limit 5';

		return $this->db->getAll($sql);


	}
示例#3
0
文件: cateadd.php 项目: wyjie/bool
<?php

define('ACC', true);
require '../include/init.php';
$cat = new CatModel();
$catlist = $cat->select();
$catlist = $cat->getCatTree($catlist);
include ROOT . 'view/admin/templates/cateadd.html';
示例#4
0
//接收传过来的栏目ID
$cat_id = isset($_GET['cat_id'])?$_GET['cat_id'] + 0 : 0;

//查找栏目
$cat = new CatModel();
$category = $cat->find($cat_id);


if(empty($category)){
	header('location: index.php');
	exit;
}

//取出树状导航

$cats = $cat->select(); //取出所有栏目

$sort = $cat->getCatTree($cats, 0, 1); //把取出的栏目排序

//取出面包屑导航
$nav = $cat->getTree($cat_id);


//取出栏目下的商品
$goods = new GoodsModel();
$goodlist = $goods->catGoods($cat_id);

/*
echo '<pre>';
print_r($goodlist);
echo '</pre>';
示例#5
0
文件: category.php 项目: wyjie/bool
$cat_id = isset($_GET['cat_id']) ? $_GET['cat_id'] + 0 : 0;
$page = isset($_GET['page']) ? $_GET['page'] + 0 : 1;
if ($page < 1) {
    $page = 1;
}
$goodsModel = new GoodsModel();
$total = $goodsModel->catGoodsCount($cat_id);
// 每页取2条
$perpage = 2;
if ($page > ceil($total / $perpage)) {
    $page = 1;
}
$offset = ($page - 1) * $perpage;
$pagetool = new PageTool($total, $page, $perpage);
$pagecode = $pagetool->show();
$cat = new CatModel();
$category = $cat->find($cat_id);
if (empty($category)) {
    header('location: index.php');
    exit;
}
// 取出树状导航
$cats = $cat->select();
// 获取所有的栏目
$sort = $cat->getCatTree($cats, 0, 1);
// 取出面包屑导航
$nav = $cat->getTree($cat_id);
// 取出栏目下的商品
$goods = new GoodsModel();
$goodslist = $goods->catGoods($cat_id, $offset, $perpage);
include ROOT . 'view/front/lanmu.html';
示例#6
0
<?php
//栏目编辑Control
define('ACC', true);
require('../include/init.php');
$cat_id = $_GET['cat_id'] + 0;

$cat = new CatModel();
$catinfo = $cat->find($cat_id); //取出要找的一行数据

$catlist = $cat->select(); //取出数据
$catlist = $cat->getCatTree($catlist); //无限级分类

/*
echo '<pre>';
print_r($catlist);
echo '</pre>';
*/

require(ROOT.'view/admin/templates/catedit.html');
?>