public function _initialize(){
$category=M('category');//实例化分类表
$contact=M('contact');
$about=M('about');
$contact=M('contact');
$lis=$contact->where('id=1')->find();
$this->assign('con',$lis);
$list=$category->where('prev_category_id=1 and menu=1')->select();
$this->assign('cate',$list);
if(!in_array(strtolower(ACTION_NAME),array('products_details','news_details'))){
$nowc=$category->where('prev_category_id=1 and controller="'.strtolower(ACTION_NAME).'"')->find();
}
if(strtolower(ACTION_NAME)=='products_details'){
$child=$category->where('prev_category_id=7')->select();
$this->assign('cat',$child);
$list=M('products')->where('id='.$_GET['cid'])->find();
$this->assign('data',$list);
}elseif(strtolower(ACTION_NAME)=='news_details'){
$child=$category->where('prev_category_id=5')->select();
$this->assign('cat',$child);
$list=M('news')->where('id='.$_GET['cid'])->find();
$this->assign('data',$list);
}elseif(strtolower(ACTION_NAME)!='index'){
$childc=$category->where('prev_category_id='.$nowc['id'])->select();
$this->assign('cat',$childc);
$mod='$'.strtolower(ACTION_NAME);
$$mod=M(strtolower(ACTION_NAME));
$data=$$mod->where('category_id='.$childc[0]['id'])->select();
$this->assign('data',$data);
$this->assign('title',$nowc['name']);
}
$banner=M('banner');
switch (strtolower(ACTION_NAME)) {//根据控制器参数的值做判断条件,获取banner的位置信息,在控制器参数为新闻详情或产品详情时赋对应值给title变量
case 'index':
$title='首页';
$bannerType=1;
break;
case 'about':
$bannerType=2;
break;
case 'news':
$bannerType=3;
break;
case 'news_details':
$bannerType=4;
break;
case 'products':
$bannerType=5;
break;
case 'products_details':
$bannerType=6;
break;
case 'contact':
$bannerType=7;
break;
default:
$bannerType=0;
break;
}
$ban=$banner->where('place='.$bannerType)->order('id desc')->select();
$this->assign('banner',$ban);
}