Exemplo n.º 1
0
 public function menu()
 {
     $id = intval($_GET['id']);
     $subid = intval($_GET['sub']);
     $cate = M('Menu')->where(array('status' => 1))->order('sort DESC')->select();
     $menuids = Menu::getChildsId($cate, $id);
     //传递一个父级分类ID返回所有子分类ID
     $menuids[] = $_GET['id'];
     //将父ID压入数组
     if (empty($subid)) {
         $where = array('menu_id' => array('IN', $menuids), 'status' => 1);
     } else {
         $where = array('menu_id' => $subid, 'status' => 1);
     }
     $totalRows = D('CourseView')->where($where)->count();
     $page = new Page($totalRows, 10);
     $this->list = D('CourseView')->limit($page->firstRow . ',' . $page->listRows)->where($where)->order('asort DESC,addtime DESC')->select();
     //seo
     $seo = M('Menu')->where('menu_id=' . $id)->find();
     $this->seo_set($seo['title'], $seo['kwd'], $seo['des']);
     $this->assign('page_show', $page->show());
     $this->submenu = M('Menu')->where(array('pid' => $id, 'status' => 1))->select();
     $this->display();
 }
Exemplo n.º 2
0
 public function article()
 {
     if (IS_POST) {
         //删除处理
         if (is_array($_POST['del_id']) && !empty($_POST['del_id'])) {
             foreach ($_POST['del_id'] as $article_id) {
                 //删除图片
                 $article_pic = $this->art->where('id=' . $article_id)->getField('img');
                 if ($article_pic) {
                     @unlink(BasePath . '/Uploads/' . $article_pic);
                 }
                 $this->art->where('id=' . $article_id)->delete();
             }
             $this->success("操作成功", U('article'));
             exit;
         } else {
             $this->error("请选择要操作的对象");
         }
     }
     $map = array();
     if (trim($_GET['article_title'])) {
         $map['title'] = array('like', '%' . trim($_GET['article_title']) . '%');
     }
     $ac_list = $this->art_class->order('sort DESC')->select();
     $cids = Menu::getChildsId($ac_list, intval($_GET['ac_id']));
     $cids[] = intval($_GET['ac_id']);
     $map['menu_id'] = array('IN', $cids);
     $totalRows = $this->art->where($map)->relation(true)->count();
     $page = new Page($totalRows, 10);
     $list = $this->art->where($map)->relation(true)->limit($page->firstRow . ',' . $page->listRows)->order('asort desc')->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('article_index');
 }