示例#1
0
 /**
  *  添加新的子菜单,但是要选择是 哪种类型(Article,Category,Section).
  *  从组件中找出存在的组建
  */
 function add()
 {
     //查找出子菜单,并且显示分配在左侧菜单中
     $menus = new MenuModel();
     $menu_list = $menus->select();
     $this->assign('menulist', $menu_list);
     //导入分页类
     import("ORG.Util.Page");
     //查询组件,相当于哪几种类型
     $component = new ComponentModel();
     $where = array('enabled' => 1);
     $list = $component->where($where)->select();
     $this->assign('comlist', $list);
     //得到类型
     $link = strtolower($_REQUEST['link']);
     //查询数据,如果默认为空,则显示文章列表
     if (empty($link) || $link == 'article') {
         $art = new ArticleModel();
         $count = $art->count();
         $page = new Page($count, C("PAGESIZE"));
         //完成分页
         $show = $page->show();
         //查询分页数据
         $list = $art->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
     } else {
         if ($link == 'category') {
             $cat = new CategoryModel();
             $count = $cat->count();
             $page = new Page($count, C("PAGESIZE"));
             //完成分页
             $show = $page->show();
             //查询分页数据
             $list = $cat->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
         } else {
             $sec = new SectionModel();
             $count = $sec->count();
             $page = new Page($count, C("PAGESIZE"));
             //完成分页
             $show = $page->show();
             //查询分页数据
             $list = $sec->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
         }
     }
     $this->assign('show', $show);
     $this->assign('list', $list);
     $this->assign('link', $link);
     $this->display();
 }