ecshop如何调用商品属性在任何页面方法

2016-09-02 16:28 来源:www.chinab4c.com 作者:ecshop专家

第一步:打开includes\\lib_insert.php文件在最后面的?>上面加上: /** * 调用商品属性 * * @access public * @return string */ 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]; } 第二步:直接在模板中,无论是dwt还是lib中调用,调用方法: {insert name=\'attr\' aid=属性id gid=商品编号} 调用商品的属性值 {insert name=\'attr\' aid=属性id} 调用商品的属性名