/** * 显示该父级栏目及其子级栏目所有文章 */ 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(); }
/** * 专题控制器首页 */ 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() { $m = D('Guestbook'); //**分页实现代码 $count = $m->count(); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 11); // 实例化分页类 传入总记录数和每页显示的记录数(25) $show = $Page->show(); // 分页显示输出 //**分页实现代码 $arr = $m->where("gb_dell=0")->order('gb_addtime desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); //dump($arr); //exit; //循环截取字符 substr_ext函数写在commonaction.class.php中 foreach ($arr as $k2 => $v2) { $arr[$k2]['gb_name'] = Common::substr_ext($v2['gb_name'], 0, 10, 'utf-8', ""); } foreach ($arr as $k2 => $v2) { $arr[$k2]['gb_title'] = Common::substr_ext($v2['gb_title'], 0, 25, 'utf-8', ""); } foreach ($arr as $k2 => $v2) { $arr[$k2]['gb_content'] = Common::substr_ext($v2['gb_content'], 0, 100, 'utf-8', ""); } foreach ($arr as $k2 => $v2) { $arr[$k2]['gb_recontent'] = Common::substr_ext($v2['gb_recontent'], 0, 100, 'utf-8', ""); } // dump($arr); // exit; $this->assign('page', $show); $this->assign('vlist', $arr); $this->assign('count', $count); $this->display(); }
/** * 显示轮播广告 */ public function index() { //查询指定id的栏目信息 $id = I('get.id'); //类别ID $topnav = M('Adnav')->where("id={$id}")->select(); // dump($topnav); // exit; //查询指定id的栏目下的所有文章 foreach ($topnav as $k => $v) { //查询数据,没有分页 $where['advert_nav'] = $id; $topnav[$k]['news'] = D('Advert')->where($where)->order('advert_sort')->relation(true)->select(); $result = $topnav[$k]['news']; } //**分页实现代码 $count = count($result); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 5); // 实例化分页类 传入总记录数和每页显示的记录数(25) $show = $Page->show(); // 分页显示输出 //**分页实现代码 //查询指定id的栏目下的所有文章 foreach ($topnav as $k => $v) { //查询数据,没有分页 $where['advert_nav'] = $id; $topnav[$k]['news'] = D('Advert')->where($where)->relation(true)->limit($Page->firstRow . ',' . $Page->listRows)->order('advert_sort,id desc')->select(); $result = $topnav[$k]['news']; } //循环截取字符 substr_ext函数写在commonaction.class.php中 foreach ($result as $k2 => $v2) { $result[$k2]['advert_name'] = Common::substr_ext($v2['advert_name'], 0, 12, 'utf-8', ""); } foreach ($result as $k2 => $v2) { $result[$k2]['advert_size'] = get_byte($v2['advert_size']); } // dump($result); // exit; $this->assign('page', $show); // 赋值分页输出 $this->assign('vlist', $result); $this->assign('nav', $id); $this->assign('count', $count); $this->display(); }
/** * 新闻列表 * @date: 2015-12-11 上午02:11:24 * @author: zhouqg * @param: variable * @return: */ public function index() { // 搜索功能 $keyword = I('post.keyword'); if (!empty($keyword)) { $where['news_title'] = array('like', "%{$keyword}%"); $this->assign('keyword', $keyword); } //栏目选择 $selColumn = I('post.selColumn'); if (!empty($selColumn) && $selColumn != '0') { $where['column_id'] = $selColumn; $this->assign('selColumn', $selColumn); } //获得栏目列表 $m = D('Column')->where(array('model_id' => $this->modelId))->order('column_sort ASC')->select(); $m = Category::unlimitedForLevel($m, ' ├─'); $this->assign('Column', $m); $m = D('News'); $where['news_del'] = '0'; $order = 'news_sort,news_addtime desc'; $result = D('News')->where($where)->relation(true)->select(); //**分页实现代码 $count = count($result); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 15); // 实例化分页类 传入总记录数和每页显示的记录数(20) $show = $Page->show(); // 分页显示输出 $this->assign('page', $show); // 赋值分页输出 $this->assign('count', $count); // 赋值分页输出 //**分页实现代码 $result = D('News')->where($where)->relation(true)->limit($Page->firstRow . ',' . $Page->listRows)->order($order)->select(); foreach ($result as $k => $v) { $result[$k]['news_title'] = Common::substr_ext($v['news_title'], 0, 16, 'utf-8', ""); } // dump($result); // exit; $this->assign('vlist', $result); //赋值 $this->display(); }
/** * 登录用户信息页面 */ public function index() { //****SEO信息 $mi = M('Config'); $data = $mi->field('config_webname,config_webkw,config_cp')->find(); //dump($data); //exit; $title = '会员中心' . ' - ' . $data['config_webname']; $keywords = '会员中心' . ',' . $data['config_webkw']; $description = '会员中心' . ',' . $data['config_cp']; $this->assign('title', $title); $this->assign('keywords', $keywords); $this->assign('description', $description); //显示通知公告 $m = D('Notice'); $arr = $m->order('notice_time')->select(); foreach ($arr as $k2 => $v2) { $arr[$k2]['notice_title'] = Common::substr_ext($v2['notice_title'], 0, 25, 'utf-8', ""); } // dump($arr); // exit; $this->assign('vlist', $arr); //**判断是否登录,否则强制到登录页面 session_start(); if (!isset($_SESSION['user_email']) || $_SESSION['user_email'] == '') { //$this->redirect('user/login'); $this->error('请先登录', 'login'); } //**显示登录用户信息 $user_email = $_SESSION["user_email"]; //dump($user_email); //exit; $m = D('User'); $data['user_email'] = $user_email; //$data['username']='******'; $arr = $m->where($data)->select(); $arr = $arr[0]; //dump($arr); //exit; $this->assign('v', $arr); $this->display(); }
/** * 产品列表 * @date: 2015-12-25 上午02:11:24 * @author: zhouqg * @param: variable * @return: */ public function index() { //栏目选择 $selColumn = I('post.selColumn'); if (!empty($selColumn) && $selColumn != '0') { $where['column_id'] = $selColumn; $this->assign('selColumn', $selColumn); } //获得栏目列表 $m = D('Column')->where(array('model_id' => $this->modelId))->order('column_sort ASC')->select(); $m = Category::unlimitedForLevel($m, ' ├─'); $this->assign('Column', $m); $where['product_del'] = '0'; $order = 'product_sort,product_createtime desc'; $result = D('Product')->where($where)->relation(true)->select(); foreach ($result as $k => $v) { $result[$k]['news_title'] = Common::substr_ext($v['news_title'], 0, 16, 'utf-8', ""); } // dump($result); // exit; $this->assign('vlist', $result); //赋值 $this->display(); }
/** * 留言板展示 */ public function index() { import('Class.Common', APP_PATH); //文件在当前项目目录下的class目录 $id = I('get.id'); //类别ID //没有栏目id时,定义栏目的名字,用于全局导航 if ($id == null) { $this->assign('ifid', not); $url = 'guestbook'; //定义url的后缀名字 } //dump($url); //exit; //**获取当前栏目的信息 $m = D('Column'); $data['column_ename'] = $url; $topcate = $m->where($data)->select(); $this->assign('nav_list', $topcate); //dump($topcate); //exit; //****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; //模板显示文章 $m = D('Guestbook'); //$arr=$m->select(); // dump($arr); // exit; //**分页实现代码 $count = $m->count(); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 3); // 实例化分页类 传入总记录数和每页显示的记录数(25) $show = $Page->show(); // 分页显示输出 //**分页实现代码 $arr = $m->where("gb_dell=0")->order('gb_addtime desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); //截取部分标题 foreach ($arr as $k2 => $v2) { $arr[$k2]['title'] = Common::substr_ext($v2['title'], 0, 20, 'utf-8', ""); } foreach ($arr as $k2 => $v2) { $arr[$k2]['content'] = htmlspecialchars_decode($v2['content']); } // dump($arr); // exit; //**分页实现代码 $this->assign('page', $show); // 赋值分页输出 //**分页实现代码 $this->assign('vlist', $arr); $this->display(); }
/** * 回复留言 * @date: 2015-12-31 上午02:24:35 * @author: zhouqg * @param: variable * @return: */ public function edit() { $id = I('get.id'); $m = D('Message_exp'); //读取数据库模型model文件,关联模型。 //留言内容 $where['mes_exp_pid'] = $id; $where['mes_exp_type'] = '0'; $arr = $m->where($where)->find(); $user = Common::get_user($arr['answerer_id'], $arr['answerer_type']); $arr['user'] = $user; $this->assign('v', $arr); //回复的内容 $where['mes_exp_type'] = '1'; $where['mes_exp_show'] = '0'; $arr = $m->where($where)->order('mes_exp_addtime asc')->select(); foreach ($arr as $k => $v) { $arr[$k]['user'] = Common::get_user($v['answerer_id'], $v['answerer_type']); } $this->assign('vlist', $arr); //当前管理员信息 $admin = Common::get_user($_SESSION['id'], '2'); $this->assign('ad', $admin); $this->display(); }
/** * 查询数据表单处理类文件 */ public function search() { $keyword = I('get.keyword'); //判断存在id if ($id == null) { $this->assign('ifid', not); } if ($keyword == null) { $this->error('请输入搜索关键字!'); } $m = D('notice'); $data['notice_title'] = array('like', "%{$keyword}%"); $arr = $m->where($data)->select(); //**分页实现代码 $count = count($arr); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 11); // 实例化分页类 传入总记录数和每页显示的记录数(25) $show = $Page->show(); // 分页显示输出 //**分页实现代码 $data['notice_title'] = array('like', "%{$keyword}%"); $arr = $m->where($data)->limit($Page->firstRow . ',' . $Page->listRows)->select(); //dump($arr); //exit; foreach ($arr as $k2 => $v2) { $arr[$k2]['notice_title'] = Common::substr_ext($v2['notice_title'], 0, 30, 'utf-8', ""); } if ($arr == null) { $this->error('不存在该公告'); } else { //**分页实现代码 $this->assign('page', $show); // 赋值分页输出 //**分页实现代码 $this->assign('vlist', $arr); //在新查询到的数据再分配给前台模板显示 $this->assign('count', $count); $this->display('index'); //指定模板 } }
/** * 显示鉴定属性id下的文章 */ public function news() { //查询指定id的栏目信息 $id = I('get.id'); //类别ID $m = D('Attr'); $data['g.id'] = $id; $field = 'g.id,g.attr_name,g.attr_color,i.news_id,i.attr_id,r.nv_id,r.news_title,r.news_hits,r.news_author,r.news_addtime,r.news_updatetime,r.news_sort,f.column_name'; $result = $m->alias('g')->join('LEFT JOIN tuzi_attr_news i ON i.attr_id = g.id')->join('LEFT JOIN tuzi_news r ON r.id = i.news_id')->join('LEFT JOIN tuzi_column f ON f.id = r.nv_id')->field($field)->order('r.news_sort desc')->where($data)->select(); // dump($result); // exit; //**分页实现代码 $count = count($result); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 11); // 实例化分页类 传入总记录数和每页显示的记录数(25) $show = $Page->show(); // 分页显示输出 //**分页实现代码 $data['g.id'] = $id; $field = 'g.id,g.attr_name,g.attr_color,i.news_id,i.attr_id,r.nv_id,r.news_title,r.news_hits,r.news_author,r.news_addtime,r.news_updatetime,r.news_sort,f.column_name'; $result = $m->alias('g')->join('LEFT JOIN tuzi_attr_news i ON i.attr_id = g.id')->join('LEFT JOIN tuzi_news r ON r.id = i.news_id')->join('LEFT JOIN tuzi_column f ON f.id = r.nv_id')->field($field)->order('r.news_sort desc')->where($data)->limit($Page->firstRow . ',' . $Page->listRows)->select(); // 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', ""); } //**分页实现代码 $this->assign('page', $show); // 赋值分页输出 $this->assign('count', $count); // 赋值分页输出 $this->assign('module', MODULE_NAME); // 赋值分页输出 //**分页实现代码 $this->assign('vcolumn', $topcate); $this->assign('vlist', $result); $this->assign('nav', $id); $this->display(); }
/** * 查询数据表单处理类文件 */ public function search() { // dump($_GET); // exit; C('TOKEN_ON', false); //关闭表单令牌 $keyword = I('get.keyword'); //判断存在id if ($id == null) { $this->assign('ifid', not); } if ($keyword == null) { $this->error('请输入搜索关键字!'); } $m = D('News'); $data['news_title'] = array('like', "%{$keyword}%"); $arr = $m->where($data)->where('news_dell=0')->relation(true)->select(); // dump($arr); // exit; //**分页实现代码 $count = count($arr); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 11); // 实例化分页类 传入总记录数和每页显示的记录数(25) $show = $Page->show(); // 分页显示输出 //**分页实现代码 $arr = $m->where($data)->where('news_dell=0')->relation(true)->limit($Page->firstRow . ',' . $Page->listRows)->select(); // dump($arr); // exit; foreach ($arr as $k2 => $v2) { $arr[$k2]['news_title'] = Common::substr_ext($v2['news_title'], 0, 16, 'utf-8', ""); } if ($arr == null) { $this->error('没有数据'); } else { //**分页实现代码 $this->assign('page', $show); // 赋值分页输出 //**分页实现代码 $this->assign('vlist', $arr); //在新查询到的数据再分配给前台模板显示 $this->assign('module', MODULE_NAME); $this->assign('count', $count); //在新查询到的数据再分配给前台模板显示 $this->display('index'); //指定模板 } }