zoukankan      html  css  js  c++  java
  • ECSHOP任意页面调用商品属性

    直接用下面的方法,就可以在ECSHOP的任意页面调用商品属性

    1、打开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];

    }


    --------------------------------------------------------------

    注意要加在  ?>  的前面


    2、接下来就可以直接在
    ECSHOP模板中(dwt文件、lib文件皆可)中调用,


    调用方法:


    {insert name='attr' aid=属性id gid=商品编号} 调用商品的属性值


    {insert name='attr' aid=属性id} 调用商品的属性


    经过上面修改代码或增加代码后,就可以在ECSHOP的任意页面调用商品属性了。

  • 相关阅读:
    CentOS7使用firewalld打开关闭防火墙与端口
    SELinux: Could not downgrade policy file
    CentOS 安装 semanage 命令
    漏洞: RHSA2017:3075: wget security update
    CentOS7增加或修改SSH端口号
    gnl's not lao 道德经 英文版
    当代 IT 大牛排行榜
    当代 IT 大牛排行榜
    2008 年个人回忆与总结
    Patch2 for NetBeans IDE 6.5 Now Available
  • 原文地址:https://www.cnblogs.com/wangblognet/p/2809951.html
Copyright © 2011-2022 走看看