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

  • 相关阅读:
    三层框架(原始版)
    Java虚拟机之内存区域
    JDK和JRE的区别
    cookie和session区别与联系
    DAO、Service、Controller及View层级结构梳理
    JavaWeb-四大域对象复习
    Mybatis-实现逆向代理
    Springboot-实现热部署
    排序算法-冒泡排序
    【ERROR 1064 (42000)】MySQL中使用mysqladmin或set修改root密码时提示语法错误
  • 原文地址:https://www.cnblogs.com/xu--jun/p/6509953.html
Copyright © 2011-2022 走看看