-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct_category.php
82 lines (68 loc) · 3.48 KB
/
product_category.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* DouPHP
* --------------------------------------------------------------------------------------------------
* 版权所有 2013-2015 漳州豆壳网络科技有限公司,并保留所有权利。
* 网站地址: http://www.douco.com
* --------------------------------------------------------------------------------------------------
* 这不是一个自由软件!您只能在遵守授权协议前提下对程序代码进行修改和使用;不允许对程序代码以任何形式任何目的的再发布。
* 授权协议:http://www.douco.com/license.html
* --------------------------------------------------------------------------------------------------
* Author: DouCo
* Release Date: 2015-10-16
*/
define('IN_DOUCO', true);
require (dirname(__FILE__) . '/include/init.php');
// 验证并获取合法的ID,如果不合法将其设定为-1
$cat_id = $firewall->get_legal_id('product_category', $_REQUEST['id'], $_REQUEST['unique_id']);
if ($cat_id == -1) {
$dou->dou_msg($GLOBALS['_LANG']['page_wrong'], ROOT_URL);
} else {
$where = ' WHERE cat_id IN (' . $cat_id . $dou->dou_child_id('product_category', $cat_id) . ')';
}
// 获取分页信息
$page = $check->is_number($_REQUEST['page']) ? trim($_REQUEST['page']) : 1;
$limit = $dou->pager('product', ($_DISPLAY['product'] ? $_DISPLAY['product'] : 10), $page, $dou->rewrite_url('product_category', $cat_id), $where);
/* 获取产品列表 */
$sql = "SELECT id, cat_id, name, price, content, image, add_time, description FROM " . $dou->table('product') . $where . " ORDER BY id DESC" . $limit;
$query = $dou->query($sql);
while ($row = $dou->fetch_array($query)) {
$url = $dou->rewrite_url('product', $row['id']); // 获取经过伪静态产品链接
$add_time = date("Y-m-d", $row['add_time']);
// 如果描述不存在则自动从详细介绍中截取
$description = $row['description'] ? $row['description'] : $dou->dou_substr($row['content'], 150, false);
// 生成缩略图的文件名
$image = explode(".", $row['image']);
$thumb = ROOT_URL . $image[0] . "_thumb." . $image[1];
// 格式化价格
$price = $row['price'] > 0 ? $dou->price_format($row['price']) : $_LANG['price_discuss'];
$product_list[] = array (
"id" => $row['id'],
"cat_id" => $row['cat_id'],
"name" => $row['name'],
"price" => $price,
"thumb" => $thumb,
"add_time" => $add_time,
"description" => $description,
"url" => $url
);
}
// 获取分类信息
$sql = "SELECT * FROM " . $dou->table('product_category') . " WHERE cat_id = '$cat_id'";
$query = $dou->query($sql);
$cate_info = $dou->fetch_assoc($query);
// 赋值给模板-meta和title信息
$smarty->assign('page_title', $dou->page_title('product_category', $cat_id));
$smarty->assign('keywords', $cate_info['keywords']);
$smarty->assign('description', $cate_info['description']);
// 赋值给模板-导航栏
$smarty->assign('nav_top_list', $dou->get_nav('top'));
$smarty->assign('nav_middle_list', $dou->get_nav('middle', '0', 'product_category', $cat_id, $cate_info['parent_id']));
$smarty->assign('nav_bottom_list', $dou->get_nav('bottom'));
// 赋值给模板-数据
$smarty->assign('ur_here', $dou->ur_here('product_category', $cat_id));
$smarty->assign('cate_info', $cate_info);
$smarty->assign('product_category', $dou->get_category('product_category', 0, $cat_id));
$smarty->assign('product_list', $product_list);
$smarty->display('product_category.dwt');
?>