public function detail() { $id = intval($_GET['lid']); $info = M('News')->where(array('id' => $id, 'uid' => 0, 'status' => 1))->find(); if (empty($info)) { $this->error('抱歉,没有找到该文章哦!'); } else { $menu = M('Menu')->where(array('status' => 1))->order('sort DESC')->select(); $info['menu'] = Menu::getParents($menu, $info['menu_id']); $menus = menu::unlimitedForLayer($menu); $this->news = M('News')->where(array('status' => 1))->field(array('id', 'uid', 'title', 'addtime'))->order('asort DESC,addtime DESC')->limit(12)->select(); $this->menu = $menus; $this->info = $info; $this->seo_set($info['title']); $this->display(); } }
public function news() { if (IS_POST) { //删除处理 if (is_array($_POST['del_id']) && !empty($_POST['del_id'])) { foreach ($_POST['del_id'] as $article_id) { //删除图片 $article_pic = D('News')->where('id=' . $article_id)->getField('img'); if ($article_pic) { @unlink(BasePath . '/Uploads/' . $article_pic); } D('News')->where('id=' . $article_id)->delete(); } $this->success("操作成功", U('news')); exit; } else { $this->error("请选择要操作的对象"); } } $map = array(); if ($_GET['article_title']) { $map['title'] = array('like', '%' . $_GET['article_title'] . '%'); } if (intval($_GET['ac_id'])) { $map['menu_id'] = array('eq', intval($_GET['ac_id'])); } $totalRows = D('News')->where($map)->relation(true)->count(); $page = new Page($totalRows, 10); $list = D('News')->where($map)->relation(true)->limit($page->firstRow . ',' . $page->listRows)->order('asort desc')->select(); $ac_list = $this->art_class->order('sort asc')->select(); foreach ($list as $key => $val) { $list[$key]['Menu'] = Menu::getParents($ac_list, $val['Menu']['menu_id']); } $ac_list = Menu::unlimitedForLayer($ac_list); $this->assign('ac_list', $ac_list); $this->assign('list', $list); $this->assign('search', $_GET); $this->assign('show_page', $page->show()); $this->display('news_index'); }