多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
例如访问: http://thinkcmf/agent/menu/edit/id/10 ## 代码 ``` <?php namespace app\agent\controller; use think\Controller; use think\Db; use tree\Tree; class MenuController extends Controller { /** * 后台菜单编辑 */ public function edit() { $tree = new Tree(); $id = $this->request->param("id", 0, 'intval'); $rs = Db::name('AdminMenu')->where(["id" => $id])->find(); $result = Db::name('AdminMenu')->order(["list_order" => "ASC"])->select(); $array = []; foreach ($result as $r) { $r['selected'] = $r['id'] == $rs['parent_id'] ? 'selected' : ''; $array[] = $r; } $str = "<option value='\$id' \$selected>\$spacer \$name</option>"; $tree->init($array); $selectCategory = $tree->getTree(0, $str); $this->assign("data", $rs); $this->assign("select_category", $selectCategory); return $this->fetch(); } } ``` ## 要点解析 不多说,如图: ![mark](http://qiniu.newthink.cc/blog/20171019-122108114.png)