Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[分享] 为品牌空间首页增加自定义商铺显示

[复制链接]
bjmingbo 发表于 2011-12-27 16:32:43 | 显示全部楼层 |阅读模式
效果如下截图所示:


演示页面少儿信息大全

本文首发站优思美少儿影音
一共需要修改三个文件,详细及图文教程请访问:
为品牌空间首页增加自定义商铺显示
http://www.yousimei.com/forum.ph ... =4441&fromuid=1


1、需要修改index.php文件
  1. if(!empty($url)) {
  2.         header("HTTP/1.1 301 Moved Permanently");
  3.         header("location: $url");
  4. }

  5. include template('templates/site/default/index.html.php', 1);

  6. ob_out();

  7. ?>
复制代码
在上面代码前添加下面代码:
  1. //首页少儿用品店铺
  2. $shaoeryongpin = array();
  3.   $query = DB::query("SELECT a.itemid,a.subject,b.ext_54 FROM ".DB::table('shopitems')." a LEFT JOIN ".DB::table('shopmessage')." b ON a.itemid =b.itemid WHERE a.itemid != '0' AND a.grade>2 AND a.region=164 AND (a.catid=158 or a.catid=159 or a.catid=160 or a.catid=161 or a.catid=165 or a.catid=157  or a.catid=156) ORDER BY a.itemid LIMIT 8");
  4. while($row = DB::fetch($query)) {
  5.         $shaoeryongpin [$row['itemid']]['itemid'] = $row['itemid'];
  6.         $shaoeryongpin [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
  7.         $shaoeryongpin [$row['itemid']]['ext_54'] = $row['ext_54'];

  8. }


  9. //首页学校信息大全
  10. $xuexiaoxinxidaquan = array();
  11.   $query = DB::query("SELECT a.itemid,a.subject,b.ext_54 FROM ".DB::table('shopitems')." a LEFT JOIN ".DB::table('shopmessage')." b ON a.itemid =b.itemid WHERE a.itemid != '0' AND a.grade>2 AND a.region=164 AND (a.catid=145 or a.catid=146 or a.catid=201) ORDER BY a.itemid LIMIT 8");
  12. while($row = DB::fetch($query)) {
  13.         $xuexiaoxinxidaquan [$row['itemid']]['itemid'] = $row['itemid'];
  14.         $xuexiaoxinxidaquan [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
  15.         $xuexiaoxinxidaquan [$row['itemid']]['ext_54'] = $row['ext_54'];

  16. }




  17. //首页培训机构大全
  18. $peixunjigou = array();
  19.   $query = DB::query("SELECT a.itemid,a.subject,b.ext_54 FROM ".DB::table('shopitems')." a LEFT JOIN ".DB::table('shopmessage')." b ON a.itemid =b.itemid WHERE a.itemid != '0' AND a.grade>2 AND a.region=164 AND (a.catid=194 or a.catid=195 or a.catid=196) ORDER BY a.itemid LIMIT 8");
  20. while($row = DB::fetch($query)) {
  21.         $peixunjigou [$row['itemid']]['itemid'] = $row['itemid'];
  22.         $peixunjigou [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
  23.         $peixunjigou [$row['itemid']]['ext_54'] = $row['ext_54'];

  24. }





  25. //首页孕婴服务大全
  26. $yunyingfuwu = array();
  27.   $query = DB::query("SELECT a.itemid,a.subject,b.ext_54 FROM ".DB::table('shopitems')." a LEFT JOIN ".DB::table('shopmessage')." b ON a.itemid =b.itemid WHERE a.itemid != '0' AND a.grade>2 AND a.region=164 AND (a.catid=192 ) ORDER BY a.itemid LIMIT 8");
  28. while($row = DB::fetch($query)) {
  29.         $yunyingfuwu [$row['itemid']]['itemid'] = $row['itemid'];
  30.         $yunyingfuwu [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
  31.         $yunyingfuwu [$row['itemid']]['ext_54'] = $row['ext_54'];

  32. }





  33. //首页摄影录像其它
  34. $shenyingluxiang = array();
  35.   $query = DB::query("SELECT a.itemid,a.subject,b.ext_54 FROM ".DB::table('shopitems')." a LEFT JOIN ".DB::table('shopmessage')." b ON a.itemid =b.itemid WHERE a.itemid != '0' AND a.grade>2 AND a.region=164 AND (a.catid=215 or a.catid=216 or a.catid=217 or a.catid=218 or a.catid=219 or a.catid=220) ORDER BY a.itemid LIMIT 8");
  36. while($row = DB::fetch($query)) {
  37.         $shenyingluxiang [$row['itemid']]['itemid'] = $row['itemid'];
  38.         $shenyingluxiang [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
  39.         $shenyingluxiang [$row['itemid']]['ext_54'] = $row['ext_54'];

  40. }
复制代码
因个人水平问题,没有做缓存,直接查询数据库。
上面代码主要建立数据库查询。

查询详解以首页摄影录像其它为例
shenyingluxiang:自定义字符串,可以自己随便定义,但后来调用要和他一一对应
a.region=164:指定店铺所属地区分类,这里在我的网站中对应河南省郑州市金水区
(a.catid=215 or a.catid=216 or a.catid=217 or a.catid=218 or a.catid=219 or a.catid=220):对应身影录像其它下面的男装、女装等
ORDER BY a.itemid:以店铺id升序排序 如果想要降序,在后面加上DESC
LIMIT 8:返回8条记录。

kvstar 发表于 2011-12-29 01:49:38 | 显示全部楼层
代码不明 {:soso_e153:}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-16 23:46 , Processed in 0.020816 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表