A-A+
ecshop首页显示商品总数以及本月更新数的方法
为了直观显示ecshop商城中一共上架了多少款产品以及每月更新了多少款产品,需要进行一个二次代码的开发,不过这个也是非常简单的,现在由夏日博客整理在商城首页显示商品的总数以及本月更新商品数量的方法。
1,首先修改 /index.php 找到如下代码:
assign_dynamic('index');
在它后边添加一些代码:
$sql="select count(*) as goods_all from ". $ecs->table('goods'); //商品总数 $smarty->assign('goodsnum_all',$db->getOne($sql)); $time_month=mktime(0,0,0,date('m')-1,1,date('Y')); $sql="select count(*) as goods_month from ". $ecs->table('goods') ." where last_update >= " . $time_month; //本月更新数 $smarty->assign('goodsnum_month',$db->getOne($sql));
2,打开首页模板文件 index.dwt,在合适的地方调用,调用如下代码:
本商城共有商品 {$goodsnum_all} 件,本月更新 {$goodsnum_month} 件
这样在我们的商城首页就显示了本商城一共有多少款产品以及本月更新了多少款产品了,这样让消费者一眼就可以看出商城共有的产品数量以及每月都有更新的产品了。