當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。