abstract:Controller/Menu.phpController/Menu.php
where(array('mid'=>$data['pid']))->item(); //需要查询的菜单列表是pid=$item['pid']的菜单列表 $data['backid'] = $item['pid']; } $data['mid'] = (int)input('get.mid'); $data['menus'] = Db::table('admin_menus')->where(array('pid'=>$data['mid']))->lists(); return View('',$data); } //添加,修改菜单 public function add() { $mid = (int)input('get.mid'); $data['item'] = Db::table('admin_menus')->where(array('mid'=>$mid))->item(); //所有可用的菜单都可能成为上级菜单 $data['all_menus'] = Db::table('admin_menus')->where(array('status'=>0))->lists(); return View('',$data); } //菜单保存 public function save() { $mid = (int)input('post.mid'); $title = trim(input('post.title')); $pid = (int)input('post.pid'); $ord = (int)input('post.ord'); $controller = trim(input('post.controller')); $method = trim(input('post.method')); $ishidden = (int)input('post.ishidden'); $status = (int)input('post.status'); if($mid){ $data =array('title' => $title, 'pid' => $pid,'ord'=>$ord,'controller'=>$controller,'method'=>$method,'ishidden'=>$ishidden,'status'=>$status); Db::table('admin_menus')->where(array('mid'=>$mid))->update($data); }else{ $data =array('title' => $title, 'pid' => $pid,'ord'=>$ord,'controller'=>$controller,'method'=>$method,'ishidden'=>$ishidden,'status'=>$status); Db::table('admin_menus')->insert($data); } exit(json_encode(array('code' => 0, 'msg' => '保存成功!'))); return View(); } public function del() { $mid = (int)input('post.mid'); Db::table('admin_menus')->where(array('mid'=>$mid))->delete(); exit(json_encode(array('code'=>0,'msg'=>'删除成功!'))); } }view/index.html
菜单管理0){ ?>
{volist name="menus" id="vo"} ID 菜单名称 排序 controller action 是否隐藏 是否禁用 操作 {/volist} {$vo.mid} {$vo.title} {$vo.ord} {$vo.controller} {$vo.method} {$vo.ishidden==0?'正常':'隐藏'} {$vo.status==0?'正常':'禁用'} view/add.html
Correcting teacher:天蓬老师Correction time:2019-09-29 19:37:52
Teacher's summary:完成的相当OK , 坚持, 你离成功很近了