當前位置: 首頁>>代碼示例>>PHP>>正文


PHP tree::get_tree_category方法代碼示例

本文整理匯總了PHP中tree::get_tree_category方法的典型用法代碼示例。如果您正苦於以下問題:PHP tree::get_tree_category方法的具體用法?PHP tree::get_tree_category怎麽用?PHP tree::get_tree_category使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tree的用法示例。


在下文中一共展示了tree::get_tree_category方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: add

 public function add($id = '')
 {
     require APPPATH . 'libraries/tree.class.php';
     if ($id) {
         $query = $this->db->where(array('catid' => $id))->get('category')->row_array();
     }
     $this->data['item'] = $query;
     $categorys = $this->categorys;
     $tree = new tree();
     $tree->icon = array('  │ ', '  ├─ ', '  └─ ');
     $tree->nbsp = '      ';
     $string = '<select name="parentid">';
     $string .= "<option value='0'>≡ 作為一級欄目 ≡</option>";
     $str = "<option value='\$catid' \$selected>\$spacer \$catname</option>;";
     $str2 = "<optgroup label='\$spacer \$catname'></optgroup>";
     $tree->init($categorys);
     $string .= $tree->get_tree_category(0, $str, $str2, $query['parentid']);
     $string .= '</select>';
     $this->data['categorys'] = $string;
     $this->repair(false);
     $this->load->view('category/add', $this->data);
 }
開發者ID:tatfan,項目名稱:fb_backend,代碼行數:22,代碼來源:category.php

示例2: select_category

 /**
  * 欄目選擇
  * @param string $file 欄目緩存文件名
  * @param intval/array $catid 別選中的ID,多選是可以是數組
  * @param string $str 屬性
  * @param string $default_option 默認選項
  * @param intval $modelid 按所屬模型篩選
  * @param intval $type 欄目類型
  * @param intval $onlysub 隻可選擇子欄目
  * @param intval $siteid 如果設置了siteid 那麽則按照siteid取
  */
 public static function select_category($file = '', $catid = 0, $str = '', $default_option = '', $modelid = 0, $type = -1, $onlysub = 0, $siteid = 0, $is_push = 0)
 {
     require_once "Tree.class.php";
     $tree = new tree();
     if (!$siteid) {
         $siteid = get_siteid();
     }
     if ($modelid) {
         $result = D('Category')->where('siteid = %d and modelid = %d', $siteid, $modelid)->select();
     } else {
         $result = D('Category')->where('siteid = %d', $siteid)->select();
     }
     $string = '<select ' . $str . '>';
     if ($default_option) {
         $string .= "<option value='0'>{$default_option}</option>";
     }
     if (is_array($result)) {
         foreach ($result as $r) {
             if ($siteid != $r['siteid'] || $type >= 0 && $r['type'] != $type) {
                 continue;
             }
             $r['selected'] = '';
             if (is_array($catid)) {
                 $r['selected'] = in_array($r['id'], $catid) ? 'selected' : '';
             } elseif (is_numeric($catid)) {
                 $r['selected'] = $catid == $r['id'] ? 'selected' : '';
             }
             $r['html_disabled'] = "0";
             if (!empty($onlysub) && $r['child'] != 0) {
                 $r['html_disabled'] = "1";
             }
             $categorys[$r['id']] = $r;
             if ($modelid && $r['modelid'] != $modelid) {
                 unset($categorys[$r['catid']]);
             }
         }
     }
     $str = "<option value='\$id' \$selected>\$spacer \$catname</option>;";
     $str2 = "<optgroup label='\$spacer \$catname'></optgroup>";
     $tree->init($categorys);
     $string .= $tree->get_tree_category(0, $str, $str2);
     $string .= '</select>';
     return $string;
 }
開發者ID:lxp521125,項目名稱:TP-Admin,代碼行數:55,代碼來源:Form.class.php


注:本文中的tree::get_tree_category方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。