当前位置: 首页>>代码示例>>PHP>>正文


PHP Data::tree方法代码示例

本文整理汇总了PHP中Data::tree方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::tree方法的具体用法?PHP Data::tree怎么用?PHP Data::tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Data的用法示例。


在下文中一共展示了Data::tree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAll

 public function getAll()
 {
     $data = $this->get();
     // p($data);exit;
     $data = Data::tree($data, 'catname', 'id');
     return $data;
 }
开发者ID:arnold1119,项目名称:cms,代码行数:7,代码来源:Category.php

示例2: update_cache

 public function update_cache()
 {
     //获得表中的所有栏目数据
     $category = Data::tree($this->all(), 'cname');
     return F("category", $category);
     //file_put_contents()储存文件缓存
 }
开发者ID:jyht,项目名称:v5,代码行数:7,代码来源:CategoryModel.class.php

示例3: edit

 public function edit()
 {
     $menu = new \system\model\Menu();
     if (IS_POST) {
         $data = json_decode(Request::post('menu'));
         foreach ($data as $m) {
             $d = [];
             if (!empty($m->id)) {
                 $d['id'] = $m->id;
             }
             $d['pid'] = intval($m->pid);
             $d['title'] = $m->title;
             $d['permission'] = $m->permission;
             $d['url'] = $m->url;
             $d['append_url'] = $m->append_url;
             $d['icon'] = $m->icon;
             $d['orderby'] = intval($m->orderby);
             $d['is_display'] = $m->is_display;
             $d['mark'] = $m->mark;
             $d['is_system'] = $m->is_system;
             if ($d['mark'] && $d['title']) {
                 $menu->replace($d);
             }
         }
         message('菜单更改成功');
     }
     $data = $menu->get()->toArray();
     $menus = Data::tree($data, 'title', 'id', 'pid');
     return view()->with('menus', json_encode($menus, JSON_UNESCAPED_UNICODE));
 }
开发者ID:houdunwang,项目名称:hdcms,代码行数:30,代码来源:Menu.php

示例4: addForum

 public function addForum()
 {
     $db = M('forum');
     if (IS_POST) {
         //处理表单提交
         $data = $_POST;
         $data['create_time'] = time();
         if ($dbid = $db->add($data)) {
             $path = MYPHP_TEMP_PATH . '/Dbid/Forum';
             is_dir($path) || mkdir($path, 0777, true);
             chmod($path, 0777);
             if (file_put_contents($path . '/forumId.txt', $dbid)) {
                 $this->success('保存版块成功', __APP__ . "?c=Forum&a=forum");
             }
         } else {
             $this->error('添加失败,请重新添加');
         }
     }
     $forum = $db->where('is_delete=0')->all();
     $count = count($forum);
     $forum = alread_column(Data::tree($forum, 'fname', 'fid', 'father_fid'));
     // p($forum);die;
     $this->assign('count', $count);
     $this->assign('forum', $forum);
     $this->display();
 }
开发者ID:sujinw,项目名称:webPHP,代码行数:26,代码来源:ForumController.class.php

示例5: edit

 public function edit()
 {
     //修改分类
     if (IS_POST) {
         if (!$this->model->editCate()) {
             $this->error($this->model->error);
         }
         $this->success('修改成功', U('Category/index'));
     }
     $cid = Q('get.cid', 0, 'intval');
     //类型循环分配
     $type = M('type')->all();
     $this->assign('typeData', $type);
     //旧数据
     $oldCate = $this->model->where("cid={$cid}")->find();
     $this->assign('oldCate', $oldCate);
     //处理分类
     $allData = $this->model->all();
     $cid = Q('cid', 0, 'intval');
     $cids = $this->getSon($cid, $allData);
     $cids[] = $cid;
     $data = $this->model->where("cid NOT IN(" . implode(',', $cids) . ")")->all();
     $data = Data::tree($data, 'cname');
     $this->assign('data', $data);
     $this->display();
 }
开发者ID:heroshadow,项目名称:shop,代码行数:26,代码来源:CategoryController.class.php

示例6: __init

 public function __init()
 {
     //获得模型实例
     $this->db = K("Node");
     $data = $this->db->order('list_order ASC, nid ASC')->all();
     $node = Data::tree($data, "title", "nid", "pid");
     $this->node = $node;
 }
开发者ID:suhanyujie,项目名称:spider,代码行数:8,代码来源:NodeController.class.php

示例7: getNode

 public function getNode()
 {
     $res = $this->where("status='1'")->all();
     if ($res) {
         $res = Data::tree($res, 'name', 'id', 'pid');
     }
     return $res;
 }
开发者ID:sujinw,项目名称:webPHP,代码行数:8,代码来源:NodeModel.class.php

示例8: columnList

 public function columnList()
 {
     $column = K('Column')->getColumnType();
     // $column = M('column')->where('display=1 AND is_delete=1')->all();
     // p(Data::tree($column,'name','id','parent_id'));
     $this->assign('column', Data::tree($column, 'name', 'id', 'parent_id'));
     $this->display();
 }
开发者ID:sujinw,项目名称:webPHP,代码行数:8,代码来源:ColumnController.class.php

示例9: getAll

 public function getAll($id = '')
 {
     if (empty($id)) {
         $data = $this->get();
         return Data::tree($data, 'title', 'id');
     } else {
         return $this->where('id', $id)->first();
     }
 }
开发者ID:arnold1119,项目名称:cms,代码行数:9,代码来源:Node.php

示例10: doSiteCategory

 public function doSiteCategory()
 {
     $data = Db::table('web_category')->where('siteid', SITEID)->orderBy('cid', 'ASC')->get() ?: [];
     foreach ($data as $k => $v) {
         $data[$k]['url'] = __ROOT__ . '/index.php?s=content/home/category&siteid=' . v('site.siteid') . '&cid=' . $v['cid'];
     }
     $data = Data::tree($data, 'title', 'cid', 'pid');
     View::with('data', $data);
     return View::make($this->template . '/content/category.php');
 }
开发者ID:houdunwang,项目名称:hdcms,代码行数:10,代码来源:content.php

示例11: getLevelCategory

 /**
  * 获取树状栏目
  * 指定cid时过滤掉cid及其子栏目
  *
  * @param int $cid
  *
  * @return mixed
  */
 public function getLevelCategory($cid = 0)
 {
     $category = Db::table('web_category')->where('siteid', SITEID)->get();
     if ($category) {
         $category = Data::tree($category, 'title', 'cid', 'pid');
         if ($cid) {
             //编辑时在栏目选择中不显示自身与子级栏目
             foreach ($category as $k => $v) {
                 if ($v['cid'] == $cid || Data::isChild($category, $v['cid'], $cid)) {
                     unset($category[$k]);
                 }
             }
         }
         return $category;
     }
 }
开发者ID:houdunwang,项目名称:hdcms,代码行数:24,代码来源:WebCategory.php

示例12: edit

 public function edit()
 {
     //打印用户自定义常量
     //print_const();
     if (IS_POST) {
         if ($this->_db->edit_category()) {
             $this->ajax(array('state' => 1, 'message' => '栏目修改成功'));
         } else {
             $this->ajax(array('state' => 0, 'message' => $this->_db->error));
         }
     } else {
         //分配编辑栏目旧的数据
         $field = $this->_db->find(Q("cid"));
         //分配所有栏目
         $category = $this->_db->all();
         $category = Data::tree($category, 'cname');
         foreach ($category as $n => $v) {
             //将父级栏目添加selected(选中状态)
             $v['selected'] = '';
             if ($field['pid'] == $v['cid']) {
                 $v['selected'] = ' selected="selected" ';
             }
             //将子栏目与自身添加disabled(禁止选择)
             $v['disabled'] = '';
             if ($field['cid'] == $v['cid'] || Data::isChild($category, $v['cid'], $field['cid'])) {
                 $v['disabled'] = ' disabled="disabled" class="disabled" ';
             }
             $category[$n] = $v;
         }
         //分配当前栏目数据
         $this->field = $field;
         //分配栏目数据
         $this->category = $category;
         $this->display();
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:36,代码来源:CategoryControl.class.php

示例13: update_cache

 /**
  * 更新缓存
  */
 public function update_cache()
 {
     $nav = $this->order('list_order ASC,nid ASC')->all();
     $data = Data::tree($nav, 'title', 'nid', 'pid');
     return cache('navigation', $data);
 }
开发者ID:jyht,项目名称:v5,代码行数:9,代码来源:NavigationModel.class.php

示例14: updateCache

 public function updateCache()
 {
     $data = $this->order("catorder ASC,cid ASC")->all();
     //缓存数据
     $cache = array();
     if ($data) {
         $data = Data::tree($data, "catname", "cid", "pid");
         foreach ($data as $cat) {
             //封面与链接栏目添加disabled属性
             $cat["disabled"] = $cat["cattype"] != 1 ? 'disabled=""' : '';
             $cat['cat_type_name'] = $this->categoryType[$cat['cattype']];
             $cache[$cat['cid']] = $cat;
         }
     }
     if (S("category", $cache, 0)) {
         return true;
     } else {
         $this->error = '栏目缓存更新失败';
         return false;
     }
 }
开发者ID:lililishuang,项目名称:hdcms,代码行数:21,代码来源:CategoryModel.class.php

示例15: updateCache

 function updateCache()
 {
     $data = $this->join(NULL)->order(array("list_order" => "ASC", 'nid' => 'ASC'))->all();
     $node = Data::tree($data, "title", "nid", "pid");
     return cache("node", $node);
 }
开发者ID:jyht,项目名称:v5,代码行数:6,代码来源:NodeModel.class.php


注:本文中的Data::tree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。