广州传奇网络

地址:广州市天河区东圃大马路富华楼C座

电话:13808825895

邮箱:gz020wbs@163.com

QQ:1564443073

网址:http://www.020wbs.com/

首页 > 二次开发Ecshop二次开发 > ECSHOP商品属性调用到任意页面方法

二次开发Ecshop二次开发

二次开发Ecshop二次开发

ECSHOP商品属性调用到任意页面方法

直接用下面的方法,就可以在ECSHOP的任意页面调用商品属性
一)、
打开includes\lib_insert.php文件,在最后面增加一个函数:
function insert_attr($arr)
{
static $static_res = NULL;
$aid= isset($arr['aid'])?$arr['aid']:0;
$gid= isset($arr['gid'])?$arr['gid']:0;
if($aid==0) return '';
if ($static_res[$aid][$gid] === NULL)
{
if($gid>0)
{
$static_res[$aid][$gid] = $GLOBALS['db']->getOne('select attr_value from ' . $GLOBALS['ecs']->table('goods_attr') . " where attr_id ='$aid' and goods_id='$gid' ");
}
else
{
$static_res[$aid][$gid] = $GLOBALS['db']->getOne('select attr_name from ' . $GLOBALS['ecs']->table('attribute') . " where attr_id ='$aid' ");
}
}
return $static_res[$aid][$gid];

}
注意要加在 ?> 的前面
二)、
接下来就可以直接在ECSHOP模板中(dwt文件、lib文件皆可)中调用,
调用方法:
{insert name='attr' aid=属性id gid=商品编号} 调用商品的属性值
{insert name='attr' aid=属性id} 调用商品的属性
是不是很简单,经过上面修改代码或增加代码后,就可以在ECSHOP的任意页面调用商品属性了。