/** * 添加新子菜单 到选中的菜单中 */ function addin() { //父菜单ID $menu_id = $_SESSION['menuid']; //首字母大写 例:Article $type = ucfirst($_POST['type']); $id = $_POST['creat_id']; //查询数据,实例化对象 if ($type == 'Article') { $obj = new ArticleModel(); } else { if ($type == 'Category') { $obj = new CategoryModel(); } else { $obj = new SectionModel(); } } $title = $obj->field('title,description')->find($id); //重写链接 $link = $id; //得到所有父菜单,然后在模板中判断选择 $menus = new MenuModel(); $menu_list = $menus->select(); //得到该父菜单下的所有子菜单 $menu_items = new MenuItemModel(); $where = array('menuid' => $menu_id); $m_items = $menu_items->where($where)->select(); //查询组建,得到相对应组建ID $components = new ComponentModel(); $coms = $components->select(); $count = count($coms); for ($i = 0; $i < $count; $i++) { if ($coms[$i]['link'] == $type) { $componentid = $coms[$i]['id']; } } $this->assign("type_id", $id); $this->assign('menu_id', $menu_id); $this->assign('link', $link); $this->assign('title', $title); $this->assign('menu_list', $menu_list); $this->assign('m_items', $m_items); $this->assign('type', $type); $this->assign('componentid', $componentid); $this->display(); }