效果如下截图所示:
演示页面少儿信息大全
本文首发站优思美少儿影音
一共需要修改三个文件,详细及图文教程请访问:
为品牌空间首页增加自定义商铺显示
http://www.yousimei.com/forum.ph ... =4441&fromuid=1
1、需要修改index.php文件- if(!empty($url)) {
- header("HTTP/1.1 301 Moved Permanently");
- header("location: $url");
- }
- include template('templates/site/default/index.html.php', 1);
- ob_out();
- ?>
复制代码 在上面代码前添加下面代码:- //首页少儿用品店铺
- $shaoeryongpin = array();
- $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");
- while($row = DB::fetch($query)) {
- $shaoeryongpin [$row['itemid']]['itemid'] = $row['itemid'];
- $shaoeryongpin [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
- $shaoeryongpin [$row['itemid']]['ext_54'] = $row['ext_54'];
- }
- //首页学校信息大全
- $xuexiaoxinxidaquan = array();
- $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");
- while($row = DB::fetch($query)) {
- $xuexiaoxinxidaquan [$row['itemid']]['itemid'] = $row['itemid'];
- $xuexiaoxinxidaquan [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
- $xuexiaoxinxidaquan [$row['itemid']]['ext_54'] = $row['ext_54'];
- }
- //首页培训机构大全
- $peixunjigou = array();
- $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");
- while($row = DB::fetch($query)) {
- $peixunjigou [$row['itemid']]['itemid'] = $row['itemid'];
- $peixunjigou [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
- $peixunjigou [$row['itemid']]['ext_54'] = $row['ext_54'];
- }
- //首页孕婴服务大全
- $yunyingfuwu = array();
- $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");
- while($row = DB::fetch($query)) {
- $yunyingfuwu [$row['itemid']]['itemid'] = $row['itemid'];
- $yunyingfuwu [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
- $yunyingfuwu [$row['itemid']]['ext_54'] = $row['ext_54'];
- }
- //首页摄影录像其它
- $shenyingluxiang = array();
- $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");
- while($row = DB::fetch($query)) {
- $shenyingluxiang [$row['itemid']]['itemid'] = $row['itemid'];
- $shenyingluxiang [$row['itemid']]['subject'] = cutstr($row['subject'],20,true);
- $shenyingluxiang [$row['itemid']]['ext_54'] = $row['ext_54'];
- }
复制代码 因个人水平问题,没有做缓存,直接查询数据库。
上面代码主要建立数据库查询。
查询详解以首页摄影录像其它为例
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条记录。
|