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


PHP Data::channelList方法代碼示例

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


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

示例1: getCategory

/**
 * 獲得欄目
 * @param int $cid 欄目cid
 * @param int $type 1 子欄目  2 父欄目
 * @param int $returnType 1 隻有cid  2 內容
 */
function getCategory($cid, $type = 1, $return = 1)
{
    $cache = cache('category');
    $cat = $catid = array();
    if ($type == 1) {
        //子欄目
        $cat = Data::channelList($cache, $cid);
    } else {
        if ($type == 2) {
            //父欄目
            $cat = parentChannel($cache, $cid);
        }
    }
    if ($return == 1) {
        //返回cid
        foreach ($cat as $c) {
            $catid[] = $c['cid'];
        }
        $catid[] = $cid;
        return $catid;
    } else {
        if ($return == 2) {
            //返回所有欄目數據
            $cat[] = $cache[$cid];
        }
    }
    return $cat;
}
開發者ID:jyht,項目名稱:v5,代碼行數:34,代碼來源:functions.php

示例2: index

 public function index()
 {
     $cache = S('category');
     $topCacegory = M('category')->where('pid=0')->all();
     $data = array();
     foreach ($topCacegory as $cat) {
         $cat['_data'] = Data::channelList($cache, $cat['cid']);
         $data[$cat['cid']] = $cat;
     }
     $this->assign('data', $data);
     $this->display();
 }
開發者ID:suhanyujie,項目名稱:spider,代碼行數:12,代碼來源:IndexController.class.php

示例3: getCategory

function getCategory($cid)
{
    $categoryCache = cache('category');
    $catData = Data::channelList($categoryCache, $cid);
    $cids = array();
    if (!empty($catData)) {
        foreach ($catData as $cat) {
            $cids[] = $cat['cid'];
        }
    }
    $cids[] = $cid;
    return $cids;
}
開發者ID:jyht,項目名稱:v5,代碼行數:13,代碼來源:functions.php

示例4: delMenu

 /**
  * 刪除菜單
  */
 public function delMenu()
 {
     $db = new \system\model\Menu();
     $id = Request::post('id');
     if ($db->where('id', $id)->where('is_system', 1)->get()) {
         message('係統菜單不允許刪除', 'back', 'error');
     }
     $data = Db::table('menu')->get();
     $menu = Data::channelList($data, $_POST['id'], " ", 'id', 'pid');
     $menu[]['id'] = $id;
     foreach ($menu as $m) {
         $db->where('id', $m['id'])->delete();
     }
     ajax(['valid' => TRUE, 'message' => '刪除成功']);
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:18,代碼來源:Menu.php

示例5: category

 public function category()
 {
     $mid = Q('mid', 0, 'intval');
     $cid = Q('cid', 0, 'intval');
     if (!$mid || !$cid) {
         $this->error('參數錯誤');
     }
     $categoryCache = cache('category');
     if (!isset($categoryCache[$cid])) {
         $this->error('欄目不存在', __ROOT__);
     }
     if ($cid) {
         $category = $categoryCache[$cid];
         //外部鏈接,直接跳轉
         if ($category['cattype'] == 3) {
             go($category['cat_redirecturl']);
         } else {
             $Model = ContentViewModel::getInstance($mid);
             $where = C('DB_PREFIX') . 'category.cid=' . $cid . " OR pid=" . $cid;
             $category['content_num'] = $Model->join('category')->where($where)->count();
             $childCategory = Data::channelList($categoryCache, $cid);
             $catWhere = array('cid' => array());
             if (!empty($childCategory)) {
                 foreach ($childCategory as $cat) {
                     $catWhere['cid'][] = $cat['cid'];
                 }
             }
             $catWhere['cid'][] = $cid;
             $category['comment_num'] = intval(M('comment')->where($catWhere)->sum());
             //欄目模板
             switch ($category['cattype']) {
                 case 1:
                     //普通欄目
                     $tpl = $category['list_tpl'];
                     break;
                 case 2:
                     //封麵欄目
                     $tpl = $category['index_tpl'];
                     break;
             }
             $tpl = 'template/' . C("WEB_STYLE") . '/' . $tpl;
             $this->assign("hdcms", $category);
             $this->display($tpl);
         }
     }
 }
開發者ID:jyht,項目名稱:v5,代碼行數:46,代碼來源:IndexControl.class.php

示例6: isset

                $where = ' pid=' . $pid;
                break;
        }
    }
}
$result = $db->where($where)->where("cat_show=1")->order()->order("catorder ASC")->limit(10)->all();
//無結果
if ($result) {
    //當前欄目,用於改變樣式
    $_self_cid = isset($_REQUEST['cid']) ? $_REQUEST['cid'] : 0;
    $categoryCache = cache('category');
    foreach ($result as $field) {
        //當前欄目樣式
        $field['class'] = $_self_cid == $field['cid'] ? "" : "";
        $field['caturl'] = Url::getCategoryUrl($field);
        $field['childcategory'] = Data::channelList($categoryCache, $field['cid']);
        ?>
							<li>
								<a href='<?php 
        echo $field['caturl'];
        ?>
'>
									<?php 
        echo $field['catname'];
        ?>
								</a>
							</li>
						<?php 
    }
}
?>
開發者ID:jyht,項目名稱:v5,代碼行數:31,代碼來源:index.html_01140.php

示例7: tree

 /**
  * 獲得樹狀數據
  * @param $data 數據
  * @param $title 字段名
  * @param string $fieldPri 主鍵id
  * @param string $fieldPid 父id
  * @return array
  */
 public static function tree($data, $title, $fieldPri = 'id', $fieldPid = 'pid')
 {
     if (!is_array($data) || empty($data)) {
         return array();
     }
     $arr = Data::channelList($data, 0, '', $fieldPri, $fieldPid);
     foreach ($arr as $k => $v) {
         $str = "";
         if ($v['_level'] > 2) {
             for ($i = 1; $i < $v['_level'] - 1; $i++) {
                 $str .= "│&nbsp;&nbsp;&nbsp;&nbsp;";
             }
         }
         if ($v['_level'] != 1) {
             $t = $title ? $v[$title] : "";
             if (isset($arr[$k + 1]) && $arr[$k + 1]['_level'] >= $arr[$k]['_level']) {
                 $arr[$k]['_name'] = $str . "├─ " . $v['_html'] . $t;
             } else {
                 $arr[$k]['_name'] = $str . "└─ " . $v['_html'] . $t;
             }
         } else {
             $arr[$k]['_name'] = $v[$title];
         }
     }
     //設置主鍵為$fieldPri
     $data = array();
     foreach ($arr as $d) {
         $data[$d[$fieldPri]] = $d;
     }
     return $data;
 }
開發者ID:xupp,項目名稱:ThinkPHP,代碼行數:39,代碼來源:Data.class.php

示例8: delCategory

 /**
  * 刪除欄目
  * @param $cid
  * @return bool
  */
 public function delCategory($cid)
 {
     if (!$cid || !isset($this->category[$cid])) {
         $this->error = 'cid參數錯誤';
         return false;
     }
     /**
      * 獲得子欄目
      */
     $category = Data::channelList($this->category, $cid);
     $category[]['cid'] = $cid;
     foreach ($category as $cat) {
         //刪除欄目文章
         $ContentModel = ContentModel::getInstance($this->category[$cat['cid']]['mid']);
         $ContentModel->where("cid=" . $cat['cid'])->del();
         //刪除欄目權限
         M("category_access")->where("cid=" . $cat['cid'])->del();
         //刪除欄目
         $this->del($cat['cid']);
     }
     //        //生成所有欄目
     //        $this->html->all_category();
     //        //生成首頁
     //        $this->html->index();
     //更新緩存
     return $this->updateCache();
 }
開發者ID:suhanyujie,項目名稱:spider,代碼行數:32,代碼來源:CategoryModel.class.php


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