Exemple #1
0
 /**
  * 菜单项 显示页面
  */
 function index()
 {
     //查找出子菜单,并且显示分配在左侧菜单中
     $menus = new MenuModel();
     $menu_list = $menus->select();
     $this->assign('menulist', $menu_list);
     import('ORG.Util.Page');
     $menus = new MenuModel();
     //判断是否有搜索
     $keyword = trim($_POST['keyword']);
     /*
     $ftype = trim($_POST['ftype']);
     if(!empty($keyword) && !empty($ftype)){
     	//如果查询的是发布字段(因为发布字段和排序都是以整数来排列的)
     	if ($ftype == 'id'){
     		$where[$ftype] = array('eq',$keyword);
     	}else{
     		$where[$ftype] = array('like','%'.$keyword.'%');
     	}			
     }
     */
     if (is_numeric($keyword)) {
         $where['id'] = array('eq', $keyword);
     } else {
         $where['title'] = array('like', '%' . $keyword . '%');
     }
     //切换状态
     $change_pub = trim($_POST['change_published']);
     if ($change_pub) {
         $where['published'] = array('eq', $change_pub);
     }
     //传值在前台判断
     $this->assign('change_pub', $change_pub);
     //得到分页需要的总文章数
     $count = $menus->where($where)->count();
     $page = new Page($count, C('PAGESIZE'));
     $show = $page->show();
     $this->assign("show", $show);
     //得到文章数据
     $list = $menus->where($where)->order('id')->limit($page->firstRow . ',' . $page->listRows)->select();
     $this->assign('mlist', $list);
     //分配配置中的每页显示多少文章到前台
     $this->assign('pagesize', C('PAGESIZE'));
     $this->display();
 }
 /**
  * 区块添加菜单
  */
 function add()
 {
     //得到名字
     $block_name = $_GET['blockname'];
     $this->assign('block_name', $block_name);
     //缓存名字
     $_SESSION['block_name'] = $block_name;
     //查询出所有已启用的菜单项
     $menu = new MenuModel();
     $list = $menu->where('published=1')->select();
     $this->assign("menus", $list);
     $this->display();
 }