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} 件

如果在全站显视如下修改

在网站根目录打开文件 includes/init.php 在适当的位置下面添加代码

我的是放在

$smarty->assign('ecs_css_path', 'themes/' . $_CFG['template'] . '/style.css');
    }

这条代码的上边

        $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));

 PS:在要在init.php 文件的最底部添加代码,可能会出现很多不可预测的事情。

再找到顶部活底部模板文件,放下面的代码放到适当的位置

本商城共有商品 {$goodsnum_all} 件,本月更新 {$goodsnum_month} 件

------------------------------------------华丽丽的分割线--------------------- ------------------------------------

源厂制造10-10000级洁净无尘车间防静电防尘用品!网址:http://www.lgfjd.com 微信号:614412
原文地址:https://www.cnblogs.com/wangblognet/p/2728149.html