20,359
社区成员
发帖
与我相关
我的任务
分享
<div class="louceng">
<?php if(!empty($output['class_list']) && is_array($output['class_list'])){
$i = 0;
?>
<?php foreach($output['class_list'] as $k=>$v){
$i++;
?>
<div class="floor_area">
<?php if ($_GET['cate_id'] == $v['sc_parent_id']){
?>
<h2><?php echo $i;?>F <?php echo $v['sc_name'];?></h2>
<?php if(!empty($output['store_list']) && is_array($output['store_list'])){?>
<ul>
<?php foreach($output['store_list'] as $skey => $store){?>
<li><a href="<?php echo ncUrl(array('act'=>'show_store','id'=>$store['store_id']),'store',$store['store_domain']);?>" title="" target="_blank"><span class="thumb size72">
<img src="<?php echo SiteUrl.'/'.(ATTACH_PATH.DS.'ad'.DS.$store['shopad']);?>" onload="javascript:DrawImage(this,240,240);" /></span></a>
</li>
<?php }?>
</ul>
<div class="clear"></div>
<?php }?>
<?php }elseif (!isset($v['child']) && $output['class_list'][$_GET['cate_id']]['sc_parent_id'] == $v['sc_parent_id']){?>
<h2><?php echo $v['sc_name'];?></h2>
<?php }?>
</div>
<?php }?>
<?php }?>
</div>
class shop_listControl extends BaseHomeControl {
/**
* 店铺列表
*/
public function indexOp(){
/**
* 读取语言包
*/
Language::read('home_store_class_index');
$lang = Language::getLangContent();
//店铺类目快速搜索
$class_list = ($h = F('store_class')) ? $h : H('store_class',true,'file');
if (!key_exists($_GET['cate_id'],$class_list)) $_GET['cate_id'] = 0;
Tpl::output('class_list',$class_list);
//店铺搜索
$model = Model();
$condition = array();
$keyword = trim($_GET['keyword']);
if(C('fullindexer.open') && !empty($keyword)){
//全文搜索
$condition = $this->full_search($keyword);
}else{
if ($keyword != ''){
$condition['store_name|store_zy'] = array('like','%'.$keyword.'%');
}
if ($_GET['user_name'] != ''){
$condition['member_name'] = trim($_GET['user_name']);
}
}
if (!empty($_GET['area_id'])){
$condition['area_id'] = array('in',$this->getAreaNextId(intval($_GET['area_id'])));
}
if ($_GET['cate_id'] > 0){
$child = array_merge((array)$class_list[$_GET['cate_id']]['child'],array($_GET['cate_id']));
$condition['sc_id'] = array('in',$child);
}
$condition['store_state'] = 1;
if (!in_array($_GET['order'],array('desc','asc'))){
unset($_GET['order']);
}
if (!in_array($_GET['key'],array('store_sales','store_credit'))){
unset($_GET['key']);
}
if(is_null($_GET['key'])){
$order = 'store_sort asc';
}else{
$order = $_GET['key'].' '.$_GET['order'];
}
if (isset($condition['store.store_id'])){
$condition['store_id'] = $condition['store.store_id'];unset($condition['store.store_id']);
}
$model_store = Model('store');
// $store_list = $model_store->where($condition)->order($order)->page(10)->select(); 20140408 bak
$store_list = $model_store->where('store_recommend=1')->order($order)->page(10)->select();
//获取店铺商品数,推荐商品列表等信息
$store_list = $model_store->getStoreSearchList($store_list);
Tpl::output('store_list',$store_list);
Tpl::output('show_page',$model->showpage(2));
//当前位置
if (intval($_GET['cate_id']) > 0){
$nav_link[1]['link'] = 'index.php?act=shop_list';
$nav_link[1]['title'] = $lang['site_search_store'];
$nav =$class_list[$_GET['cate_id']];
//如果有父级
if ($nav['sc_parent_id'] > 0){
$tmp = $class_list[$nav['sc_parent_id']];
//存入父级
$nav_link[] = array(
'title'=>$tmp['sc_name'],
'link'=>"index.php?act=shop_list&cate_id=".$nav['sc_parent_id']
);
}
//存入当前级
$nav_link[] = array(
'title'=>$nav['sc_name']
);
}else{
$nav_link[1]['link'] = 'index.php';
$nav_link[1]['title'] = $lang['homepage'];
$nav_link[2]['title'] = $lang['site_search_store'];
}
Tpl::output('nav_link_list',$nav_link);
//SEO
Model('seo')->type('index')->show();
Tpl::output('html_title',(empty($_GET['keyword']) ? '' : $_GET['keyword'].' - ').C('site_name').$lang['nc_common_search']);
Tpl::showpage('shop_list');
}
<div class="louceng">
<?php if(!empty($output['class_list']) && is_array($output['class_list'])){
$i = 0;
?>
<?php foreach($output['class_list'] as $k=>$v){
?>
<div class="floor_area">
<?php if ($_GET['cate_id'] == $v['sc_parent_id']){
$Sid= $k;
?>
<h2><?php echo ++$i;?>F <?php echo $v['cate_id'];?> <?php echo $v['sc_name'];?><a href="<?php echo ncUrl(array('act'=>'shop_search','cate_id'=>$k));?>" style="float:right" target="_blank">更多..</a></h2>
<?php if(!empty($output['store_list']) && is_array($output['store_list'])){?>
<ul>
<?php foreach($output['store_list'] as $skey => $store){?>
<li><?php echo $Sid;?><a href="<?php echo ncUrl(array('act'=>'show_store','id'=>$store['store_id']),'store',$store['store_domain']);?>" title="" target="_blank"><span class="thumb size72">
<img src="<?php echo SiteUrl.'/'.(ATTACH_PATH.DS.'ad'.DS.$store['shopad']);?>" onload="javascript:DrawImage(this,240,240);" /></span></a>
</li>
<?php }?>
</ul>
<div class="clear"></div>
<?php }?>
<?php }elseif (!isset($v['child']) && $output['class_list'][$_GET['cate_id']]['sc_parent_id'] == $v['sc_parent_id']){?>
<h2><?php echo $v['sc_name'];?></h2>
<?php }?>
</div>
<?php }?>
<?php }?>
</div>
店铺搜索PHP的代码是
//店铺搜索
$model = Model();
$condition = array();
$keyword = trim($_GET['keyword']);
if(C('fullindexer.open') && !empty($keyword)){
//全文搜索
$condition = $this->full_search($keyword);
}else{
if ($keyword != ''){
$condition['store_name|store_zy'] = array('like','%'.$keyword.'%');
}
if ($_GET['user_name'] != ''){
$condition['member_name'] = trim($_GET['user_name']);
}
}
if (!empty($_GET['area_id'])){
$condition['area_id'] = array('in',$this->getAreaNextId(intval($_GET['area_id'])));
}
if ($_GET['cate_id'] > 0){
$child = array_merge((array)$class_list[$_GET['cate_id']]['child'],array($_GET['cate_id']));
$condition['sc_id'] = array('in',$child);
}
$storeid=array($Sid);
$condition['store_state'] = 1;
$condition['store_recommend'] = 1;
if (!in_array($_GET['order'],array('desc','asc'))){
unset($_GET['order']);
}
if (!in_array($_GET['key'],array('store_sales','store_credit'))){
unset($_GET['key']);
}
if(is_null($_GET['key'])){
$order = 'store_sort asc';
}else{
$order = $_GET['key'].' '.$_GET['order'];
}
if (isset($condition['store.store_id'])){
$condition['store_id'] = $condition['store.store_id'];unset($condition['store.store_id']);
}
$model_store = Model('store');
// $store_list = $model_store->where($condition)->order($order)->page(10)->select(); 20140408 bak
$store_list = $model_store->where($condition)->order($order)->page(10)->select();
//获取店铺商品数,推荐商品列表等信息
$store_list = $model_store->getStoreSearchList($store_list);
Tpl::output('store_list',$store_list);
Tpl::output('show_page',$model->showpage(2));
麻烦帮忙看看如何循环出当前分类下的推荐店铺,现在的关键是如果将模板中第一个foreach的$k 传递到第二个foreach中进行筛选。筛选的关键代码是
$condition['store_state'] = 1;
$condition['store_recommend'] = 1;