首页 > 其他 > 详细

ecshop--在任意页面调用商品属性

时间:2016-07-01 16:33:57      阅读:173      评论:0      收藏:0      [点我收藏+]

直接用下面的方法,就可以在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的任意页面调用商品属性了。


我是在内容详情页调用的:


{insert name=‘attr‘ aid=224 }:{insert name=‘attr‘ aid=224 gid=$id}


ecshop--在任意页面调用商品属性

原文:http://11105217.blog.51cto.com/11095217/1794870

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!