利用ecshop的flash,在产品页下面(或当前产品页),轮番显示产品库的图片代码分享
* Hacks by xoao.com

  1. <?php
  2. /**
  3. * ECSHOP 轮播显示当前产品图片程序
  4. *修改自ecshop 原幻灯片轮番程序
  5. */
  6.  
  7. define('IN_ECS', true);
  8. define('INIT_NO_USERS', true);
  9. define('INIT_NO_SMARTY', true);
  10. require('./includes/init.php');
  11. header('Content-Type: application/xml; charset=utf-8');
  12. header('Cache-Control: no-cache, must-revalidate');
  13. header('Expires: Thu, 27 Mar 1975 07:38:00 GMT');
  14. header('Last-Modified: ' . date('r'));
  15. header('Pragma: no-cache');
  16.  
  17. $goods_id = isset($_REQUEST['id'])  ? intval($_REQUEST['id']) : 0;
  18. $sql = 'SELECT img_id, img_desc, thumb_url, img_url'.
  19.        ' FROM ' .$ecs->table('goods_gallery').
  20.        " WHERE goods_id = '$goods_id' ORDER BY img_id";
  21. $img_list = $db->getAll($sql);
  22. $img_count = count($img_list);
  23. if ($img_count == 0)
  24. {
  25.     /* 如果没有图片,返回商品详情页 */
  26.     header('Location: goods.php?id=' . $_REQUEST['id'] . "\n");
  27.     exit;
  28. }
  29. else
  30. {
  31. echo '<?xml version="1.0" encoding="utf-8"?><bcaster>';
  32. for ( $i = 0; $i < $img_count; $i++ )
  33. {
  34. echo '<item item_url="'. $img_list[$i]['img_url'] . '"  link="gallery.php?id=' . $goods_id .'" />';
  35. }
  36.   echo '</bcaster>';
  37. }
  38. ?>

另存为:cycle_con_img.php(这段代码生成的将是xml的格式,ecshop的幻灯片是读取xml的)
上传到根目录。

前台:拷贝ecshop首页的默认的flash的幻灯片代码到goods.dwt的想放的位置
将幻灯片里代码

  1. data/images/bcastr.swf?bcastr_xml_url=cycle_image.php

记得是两处

这样,产品库的图片就能在goods页显示幻灯片了。

如果你是第一次来这儿,欢迎订阅 feedsky RSS feed。 第一时间看到更多精彩内容,谢谢你的访问!
原文地址:http://my.xoao.com/ecshop-flash-show-img
转载请注明出处,非常感谢!
admin on 01月 20th, 2008 | File Under PHP | -