zen-cart网站,模版,采集,二次开发

首页 » ZenCart » ZenCart分析 » 阅读文章

ZenCart产品图片输出函数:zen_get_products_image()分析

2012-02-23 18:03 32638 0 发表评论
标签:


zen_get_products_image()函数位于 /includes/functions/functions_lookups.php 文件中(大约606行),主要用于产品图片输出

参数介绍

参数 作用
$product_id 产品ID
$width 图片宽度,缺省Configuration-->Images-->Small Image Width
$height 图片高度,缺省Configuration-->Images-->Small Image Height

代码分析

   function zen_get_products_image($product_id, $width = SMALL_IMAGE_WIDTH, $height = SMALL_IMAGE_HEIGHT) {
    global $db;

	//查询数据库表prducts中products_image字段
    $sql = "select p.products_image from " . TABLE_PRODUCTS . " p  where products_id='" . (int)$product_id . "'";
    $look_up = $db->Execute($sql);

	//返回图片html输出格式
	//调用zen_image()函数输出,http://www.ezencart.com/pages/607.html有介绍
	//DIR_WS_IMAGES . $look_up->fields['products_image'] 组成图片输出的url
	//调用zen_get_products_name()输出产品的名称,作为图片的title和alt属性,
	//zen_get_products_name()在http://www.ezencart.com/pages/673.html有介绍
    return zen_image(DIR_WS_IMAGES . $look_up->fields['products_image'], zen_get_products_name($product_id), $width, $height);
  }

实例

zen_get_products_image(1)

通过这几篇博文,在我们知道产品id时,就可以通过zen_get_products_image(),zen_get_products_name(),zen_get_products_display_price()获取产品图片,名称,价格的概要信息了

相关日志:

评论 共0条 (RSS 2.0) 发表评论

  1. 暂无评论,快抢沙发吧。

发表评论

  • 
  • 插入代码

联系我 Contact Me

回到页首