zoukankan      html  css  js  c++  java
  • 通过判断加载遍历首页内容

    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);
    }

  • 相关阅读:
    图灵科普系列丛书封面有奖征集(贴图送书)
    图灵2010.03书讯
    博客园图灵杯第4届博问大赛(2.27~3.27)
    asp.net运行原理
    IIS与NET桥梁
    offsetParent解释
    XML 操作类库(开源项目)
    W3C不兼容问题(最根本的原因,及解决方案)
    深入理解JavaScript系列
    HttpApplication对象创建的细节
  • 原文地址:https://www.cnblogs.com/xu--jun/p/6509953.html
Copyright © 2011-2022 走看看