/**
  * 专题控制器首页
  */
 public function index()
 {
     //查询指定id的栏目信息
     $id = I('get.id');
     //类别ID
     $topcate = M('Column')->where("id={$id}")->order('column_sort')->select();
     //dump($topcate);
     //exit;
     //查询所有栏目的信息
     $m = M('Column')->order('column_sort')->select();
     //dump($m);
     //exit;
     //查询指定id的栏目下的所有文章
     foreach ($topcate as $k => $v) {
         $cids = Category::getChildsId($m, $v['id']);
         //传递一个父级分类ID返回所有子分类ID
         $cids[] = $v['id'];
         //将父级id也压进来赋值给$cids
         //dump($cids);
         //exit;
         //查询数据,没有分页
         $where = array('nv_id' => array('IN', $cids));
         //查询新闻表nv_id字段和$cids相等时的数据
         //$News=('News');
         $topcate[$k]['news'] = D('News')->where($where)->where("news_dell=0")->relation(true)->select();
         $result = $topcate[$k]['news'];
         //**分页实现代码
         $count = count($result);
         // 查询满足要求的总记录数
         $Page = new \Think\Page($count, 11);
         // 实例化分页类 传入总记录数和每页显示的记录数(25)
         $show = $Page->show();
         // 分页显示输出
         //**分页实现代码
         //查询数据,实现分页
         $where = array('nv_id' => array('IN', $cids));
         //查询新闻表nv_id字段和$cids相等时的数据
         $m = D('News');
         $field = 'g.id,g.news_title,g.news_description,g.news_hits,g.news_addtime,g.news_updatetime,g.news_author,g.news_images,g.news_sort,g.news_pic,i.attr_color,i.attr_name,c.column_name';
         $topcate[$k]['news'] = $m->alias('g')->join('LEFT JOIN tuzi_Attr i ON i.id = g.news_type')->join('LEFT JOIN tuzi_Column c ON c.id = g.nv_id')->field($field)->where($where)->where("news_dell=0")->order('news_sort,id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
         $result = $topcate[$k]['news'];
         //查询新闻表下的所有文章   查询新闻数据赋值给字段news
         //dump($result);
         //exit;
     }
     //循环截取字符 substr_ext函数写在commonaction.class.php中
     foreach ($result as $k2 => $v2) {
         $result[$k2]['news_title'] = Common::substr_ext($v2['news_title'], 0, 16, 'utf-8', "");
     }
     //     	dump($result);
     //     	exit;
     //**分页实现代码
     $this->assign('page', $show);
     // 赋值分页输出
     //**分页实现代码
     $this->assign('vcolumn', $topcate);
     $this->assign('module', MODULE_NAME);
     $this->assign('vlist', $result);
     $this->display();
 }
 /**
  * 显示该父级栏目及其子级栏目所有文章
  */
 public function index()
 {
     //查询指定id的栏目信息
     $id = I('get.id');
     //类别ID
     $topcate = M('Column')->where("id={$id}")->order('column_sort')->select();
     //dump($topcate);
     //exit;
     //查询所有栏目的信息
     $m = M('Column')->order('column_sort')->select();
     //dump($m);
     //exit;
     //查询指定id的栏目下的所有文章
     foreach ($topcate as $k => $v) {
         $cids = Category::getChildsId($m, $v['id']);
         //传递一个父级分类ID返回所有子分类ID
         $cids[] = $v['id'];
         //将父级id也压进来赋值给$cids
         //dump($cids);
         //exit;
         //查询数据,没有分页
         $where = array('nv_id' => array('IN', $cids));
         //查询新闻表nv_id字段和$cids相等时的数据
         //$News=('News');
         $topcate[$k]['news'] = D('News')->where($where)->where("news_dell=0")->relation(true)->select();
         $result = $topcate[$k]['news'];
         //数据分页开始
         $count = count($result);
         // 查询满足要求的总记录数
         $Page = new \Think\Page($count, 15);
         // 实例化分页类 传入总记录数和每页显示的记录数(25)
         $show = $Page->show();
         // 分页显示输出
         //数据分页结束
         $where = array('nv_id' => array('IN', $cids));
         //查询新闻表nv_id字段和$cids相等时的数据
         //$News=('News');
         $topcate[$k]['news'] = D('News')->where($where)->where("news_dell=0")->relation(true)->limit($Page->firstRow . ',' . $Page->listRows)->order('news_sort,id desc')->select();
         $result = $topcate[$k]['news'];
         //dump($result);
         //exit;
     }
     //循环截取字符 substr_ext函数写在commonaction.class.php中
     foreach ($result as $k2 => $v2) {
         $result[$k2]['news_title'] = Common::substr_ext($v2['news_title'], 0, 16, 'utf-8', "");
     }
     //     	dump($result);
     //     	exit;
     //**分页实现代码
     $this->assign('page', $show);
     // 赋值分页输出
     $this->assign('count', $count);
     // 赋值分页输出
     //**分页实现代码
     $this->assign('vcolumn', $topcate);
     $this->assign('module', MODULE_NAME);
     $this->assign('vlist', $result);
     $this->assign('nav', $id);
     $this->display();
 }
Beispiel #3
0
 public function index()
 {
     //首页轮播图片
     $where['page_del'] = '0';
     $where['column_id'] = '72';
     $result = D('Page')->where($where)->order('page_sort ASC')->limit(3)->select();
     foreach ($result as $k => $v) {
         if ($k == '0') {
             //显示第一张图片
             $result[$k]['block'] = '1';
         }
         $result[$k]['page_summary'] = html_entity_decode($result[$k]['page_summary']);
     }
     $this->assign('indexImg', $result);
     //案例
     $m = D('Column')->order('column_sort ASC')->relation(true)->select();
     $pid = Category::getChildsId($m, '76');
     $pid[] = '76';
     $where = null;
     $where['product_del'] = '0';
     $where['column_id'] = array('in', $pid);
     $order = 'product_sort,product_createtime desc';
     $result = D('Product')->where($where)->order($order)->limit(14)->relation(true)->select();
     foreach ($result as $k => $v) {
         $result[$k]['url'] = __APP__ . '/Product/detail/id/' . $v['id'];
     }
     $this->assign('productList', $result);
     //新闻中心
     $where = null;
     $m = D('News');
     $where['news_del'] = '0';
     $where['column_id'] = '73';
     $order = 'news_sort,news_addtime desc';
     $result = D('News')->where($where)->order($order)->relation(true)->select();
     foreach ($result as $k => $v) {
         $result[$k]['url'] = __APP__ . '/News/detail/id/' . $v['id'];
     }
     $this->assign('newsList', $result);
     //常见问题
     $where = null;
     $m = D('News');
     $where['news_del'] = '0';
     $where['column_id'] = '75';
     $order = 'news_sort,news_addtime desc';
     $result = D('News')->where($where)->order($order)->limit('3')->relation(true)->select();
     foreach ($result as $k => $v) {
         $result[$k]['url'] = __APP__ . '/News/detail/id/' . $v['id'];
     }
     $this->assign('cjwtList', $result);
     $this->display();
 }
Beispiel #4
0
 /**
 * 文章内容
 * @date: 2016-2-01 上午06:49:55
 * @author: zhouqg
 * @param: variable
 * @return:
 */
 public function group()
 {
     //**分类id
     $id = I('get.id');
     if (!preg_match('/^\\d+$/i', $id)) {
         $this->error('url参数错误');
         exit;
         //仿制用户恶意输出url参数
     }
     $m = D('Column')->order('column_sort ASC')->relation(true)->select();
     $pid = Category::getChildsId($m, $id);
     $pid[] = $id;
     //列表
     $where = null;
     $where['product_del'] = '0';
     $where['column_id'] = array('in', $pid);
     $order = 'product_sort,product_createtime desc';
     $result = D('Product')->where($where)->order($order)->relation(true)->select();
     foreach ($result as $k => $v) {
         $result[$k]['url'] = __APP__ . '/Product/detail/id/' . $v['id'];
     }
     $this->assign('productList', $result);
     $this->display();
 }
 /**
  * 删除栏目处理
  */
 public function delete()
 {
     //**判断是否有限权,显示登录管理员信息
     $id = $_SESSION['id'];
     //dump($id);
     //exit;
     $m = D('Admin');
     $arr = $m->find($id);
     $arr = $arr['admin_type'];
     //dump($arr);
     //exit;
     if ($arr == 1) {
         // 如果不是超级管理员限权
         $this->error('你不是超级管理员,没有限权!');
     }
     //exit;
     //**删除栏目下文章操作
     //查询指定id的栏目信息
     $id = I('get.id');
     //类别ID
     $topcate = M('Column')->where("id={$id}")->order('column_sort')->select();
     //dump($topcate);
     //exit;
     //查询所有栏目的信息
     $m = M('Column')->order('column_sort')->select();
     //dump($m);
     //exit;
     //查询指定id的栏目下的所有文章
     foreach ($topcate as $k => $v) {
         $cids = Category::getChildsId($m, $v['id']);
         //传递一个父级分类ID返回所有子分类ID
         $cids[] = $v['id'];
         //将父级id也压进来赋值给$cids
         //     		dump($cids);
         //     		exit;
         //查询数据,没有分页
         $where = array('nv_id' => array('IN', $cids));
         //查询新闻表nv_id字段和$cids相等时的数据
         //$News=('News');
         $topcate[$k]['news'] = D('News')->field('id')->where($where)->where("news_dell=0")->select();
         $result = $topcate[$k]['news'];
         //查询新闻表下的所有文章   查询新闻数据赋值给字段news
     }
     //dump($result);
     //exit;
     //二维数组变一维数组
     foreach ($result as $value) {
         $new_id[] = $value['id'];
     }
     //     	dump($new_id);
     //     	exit;
     //删除栏目下的文章操作
     $m = D('News');
     //数据库表,配置文件中定义了表前缀,这里则不需要写
     //判断id是数组还是一个数值
     if (is_array($new_id)) {
         $where = 'id in(' . implode(',', $new_id) . ')';
         //implode() 函数返回一个由数组元素组合成的字符串
         //     		dump($where);
         //     		exit;
         $data['news_dell'] = 1;
         $count_News = $m->where($where)->save($data);
         //批量删除至回收站
     } else {
         $where = 'id=' . $new_id;
     }
     /**
      * 删除栏目及其子栏目操作
      */
     $m = M('Column');
     $id = I('get.id');
     //dump($id);
     //exit;
     //查询指定id的栏目信息
     $topcate = M('Column')->where("id={$id}")->order('column_sort')->select();
     //     	dump($topcate);
     //     	exit;
     $m = M('Column')->order('column_sort')->select();
     //查询指定id的栏目下的所有文章
     foreach ($topcate as $k => $v) {
         $id = Category::getChildsId($m, $v['id']);
         //传递一个父级分类ID返回所有子分类ID
         $id[] = $v['id'];
         //将父级id也压进来赋值给$cids
     }
     //     	dump($id);
     //     	exit;
     //判断id是数组还是一个数值
     if (is_array($id)) {
         $where = 'id in(' . implode(',', $id) . ')';
         //implode() 函数返回一个由数组元素组合成的字符串
     } else {
         $where = 'id=' . $id;
     }
     //     	dump($where);
     //     	exit;
     $count_Column = D('Column')->where($where)->delete();
     //修改表单用save函数
     //$count_Column=$m->where($where)->delete($id);
     if ($count_Column > 0) {
         $this->success('成功删除该栏目及所属文章', U('Category/index'), 6);
     } else {
         $this->error('删除失败');
     }
 }
 /**
  * 产品模型控制器方法
  */
 public function group()
 {
     //**字符截取函数
     import('Class.String', APP_PATH);
     //文件在当前项目目录下的class目录
     $id = I('get.id');
     //类别ID
     if (!preg_match('/^\\d+$/i', $id)) {
         $this->error('url参数错误');
         exit;
         //仿制用户恶意输出url参数
     }
     //dump($id);
     //exit;
     $m = D('Column')->order('column_sort ASC')->relation(true)->find($id);
     //获取当前栏目的名称
     $column_name = $m['column_name'];
     $this->assign('vcolumn', $column_name);
     // 		dump($m);
     // 		exit;
     if ($m['f_id'] == 0) {
         //**获取栏目的下级所有子栏目
         $m = D('Column')->order('column_sort ASC')->relation(true)->select();
         $m = Category::getChilds($m, $id);
         //获取id所有的下级栏目的信息
     } else {
         //**获取栏目的上级所有子栏目
         $m = D('Column')->order('column_sort ASC')->relation(true)->select();
         //$m=Category::getChilds($m,$id);//获取id所有的下级栏目的信息
         $m = Category::getParents($m, $id);
         //获取id所有的下级栏目的信息
         //**获取栏目父级id,并且查询下级所有子栏目
         $cid = $m['0']['id'];
         $m = D('Column')->order('column_sort ASC')->relation(true)->select();
         $m = Category::getChilds($m, $cid);
         //获取id所有的下级栏目的信息
     }
     // 		dump($m);
     // 		exit;
     //二级导航栏目的url,可根据手机站或pc站自动适配url
     $modlu = __ACTION__;
     strpos($modlu, "mobile");
     if (strpos($modlu, "mobile") == '') {
         //如果url中不存在mobile(不区分大小写)
         //栏目url
         foreach ($m as $k3 => $v3) {
             $m[$k3]['url'] = __APP__ . '/' . $v3['url'] . '/' . group . '/' . 'id' . '/' . $v3['id'];
         }
     } else {
         //栏目url
         foreach ($m as $k3 => $v3) {
             $m[$k3]['url'] = __APP__ . '/' . 'mobile' . '/' . $v3['url'] . '/' . group . '/' . 'id' . '/' . $v3['id'];
         }
     }
     $this->assign('navlist', $m);
     //var_dump($m);
     //exit;
     //**获取子栏目的上级栏目
     import('Class.Category', APP_PATH);
     //文件在当前项目目录下的class目录
     $m = D('Column')->order('column_sort ASC')->relation(true)->select();
     $m = Category::getParents($m, $id);
     //获取nv_id所有的上级栏目的信息
     //全局导航栏目的url,可根据手机站或者pc站石洞适配url
     $modlu = __ACTION__;
     strpos($modlu, "mobile");
     if (strpos($modlu, "mobile") == '') {
         //如果url中不存在mobile(不区分大小写)
         //栏目url
         foreach ($m as $k3 => $v3) {
             $m[$k3]['url'] = __APP__ . '/' . $v3['url'] . '/' . group . '/' . 'id' . '/' . $v3['id'];
         }
     } else {
         //栏目url
         foreach ($m as $k3 => $v3) {
             $m[$k3]['url'] = __APP__ . '/' . 'mobile' . '/' . $v3['url'] . '/' . group . '/' . 'id' . '/' . $v3['id'];
         }
     }
     //var_dump($m);
     //exit;
     $this->assign('topnavlist', $m);
     //**全局导航 判断设置最后一个没有尖括号
     $last = count($m) - 1;
     $this->assign('last', $last);
     //echo $last;
     //exit;
     //**获取当前栏目的信息
     $topcate = D('Column')->where("id={$id}")->order('column_sort')->relation(true)->select();
     $this->assign('nav_list', $topcate);
     //dump($topcate);
     //exit;
     if ($topcate == null) {
         $this->error('参数错误');
     }
     $this->assign('blist', $topcate);
     //****SEO信息
     $title = $topcate[0]['column_name'];
     $m = M('Config');
     $data = $m->field('config_webname')->find();
     //dump($data);
     //exit;
     $title = $title . ' - ' . $data['config_webname'];
     //dump($title);
     //exit;
     $keywords = $topcate[0]['column_keyw'];
     $description = $topcate[0]['column_descr'];
     $this->assign('title', $title);
     $this->assign('keywords', $keywords);
     $this->assign('description', $description);
     //dump($title);
     //exit;
     //**获取所有栏目的信息
     import('Class.Category', APP_PATH);
     $m = D('Column')->order('column_sort')->relation(true)->select();
     //查询所有栏目的信息
     //dump($m);
     //exit;
     //****查询指定id的栏目下的所有子栏目文章
     foreach ($topcate as $k => $v) {
         $cids = Category::getChildsId($m, $v['id']);
         //传递一个父级分类ID返回所有子分类ID
         $cids[] = $v['id'];
         //将父级id也压进来赋值给$cids
         //dump($cids);
         //exit;
         $where = array('nv_id' => array('IN', $cids));
         //查询新闻表nv_id字段和$cids相等时的数据
         $topcate[$k]['news'] = D('News')->where($where)->where("news_dell=0")->relation(true)->select();
         $result = $topcate[$k]['news'];
         //查询新闻表下的所有文章   查询新闻数据赋值给字段news
         //**分页实现代码
         $count = count($result);
         // 查询满足要求的总记录数
         $Page = new \Think\Page($count, C('PAGE_PRODUCT__HOME'));
         // 实例化分页类 传入总记录数和每页显示的记录数(25)
         $show = $Page->show();
         // 分页显示输出
         //**分页实现代码
         //查询数据,实现分页
         $where = array('nv_id' => array('IN', $cids));
         //查询新闻表nv_id字段和$cids相等时的数据
         $m = D('News');
         $field = 'g.id,g.news_content,g.news_title,g.news_pic,g.news_sort';
         $topcate[$k]['news'] = $m->alias('g')->join('LEFT JOIN tuzi_attr i ON i.id = g.news_type')->join('LEFT JOIN tuzi_column c ON c.id = g.nv_id')->field($field)->where($where)->where("news_dell=0")->order('news_sort,id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
         $result = $topcate[$k]['news'];
         //查询新闻表下的所有文章   查询新闻数据赋值给字段news
         //     		dump($result);
         //     		exit;
     }
     //循环过滤html src标签和截取中文函数  用于摘要简介  substr_ext函数写在commonaction.class.php中
     foreach ($result as $k2 => $v2) {
         $result[$k2]['news_content'] = $this->substr_ext($v2['news_content'], 0, 160, 'utf-8', "");
     }
     foreach ($result as $k2 => $v2) {
         $result[$k2]['news_title'] = $this->substr_ext($v2['news_title'], 0, 220, 'utf-8', "");
     }
     foreach ($result as $k2 => $v2) {
         $result[$k2]['news_pic'] = __ROOT__ . $v2['news_pic'];
     }
     //全局导航栏目的url,可根据手机站或者pc站石洞适配url
     $modlu = __ACTION__;
     strpos($modlu, "mobile");
     if (strpos($modlu, "mobile") == '') {
         //如果url中不存在mobile(不区分大小写)
         //文章url
         foreach ($result as $k3 => $v3) {
             $result[$k3]['url'] = __APP__ . '/' . CONTROLLER_NAME . '/' . detail . '/' . 'id' . '/' . $v3['id'];
         }
     } else {
         //文章url
         foreach ($result as $k3 => $v3) {
             $result[$k3]['url'] = __APP__ . '/' . 'mobile' . '/' . CONTROLLER_NAME . '/' . detail . '/' . 'id' . '/' . $v3['id'];
         }
     }
     // 		dump($result);
     // 		exit;
     //**分页实现代码
     $this->assign('page', $show);
     // 赋值分页输出
     //**分页实现代码
     $this->assign('vlist', $result);
     //dump($topcate);
     //dump($result);
     //exit;
     $this->display();
 }