public function test(){
$category = D ( 'Category' )->getTree ();
foreach ( $category as $k => $v ) {
$cid=array();
array_push($cid,$v['id']);
foreach ( $v ['_'] as $ks => $vs ) {
array_push($cid,$vs['id']);
foreach ( $vs ['_'] as $kgs => $vgs ) {
array_push($cid,$vgs['id']);
}
}
$category [$k] ['doc'] = array ();
$map['category_id']=array("in",$cid);
$map['status']=1;
$category [$k] ['doc'] = M('Document')->where($map)->select();
}
$this->assign ( 'category', $category );
$this->display();
}
使用:
<volist name="category" id="vo">
{$vo.title}<Br>
<volist name="vo.doc" id="article">
{$article.create_time|date='Y-m-d',###}-<a href="{:U('Article/detail?id='.$article['id'])}">{$article.title}</a><br>
</volist>
</volist>
$category = D ( 'Category' )->getTree ();
foreach ( $category as $k => $v ) {
$cid=array();
array_push($cid,$v['id']);
foreach ( $v ['_'] as $ks => $vs ) {
array_push($cid,$vs['id']);
foreach ( $vs ['_'] as $kgs => $vgs ) {
array_push($cid,$vgs['id']);
}
}
$category [$k] ['doc'] = array ();
$map['category_id']=array("in",$cid);
$map['status']=1;
$category [$k] ['doc'] = M('Document')->where($map)->select();
}
$this->assign ( 'category', $category );
$this->display();
}
使用:
<volist name="category" id="vo">
{$vo.title}<Br>
<volist name="vo.doc" id="article">
{$article.create_time|date='Y-m-d',###}-<a href="{:U('Article/detail?id='.$article['id'])}">{$article.title}</a><br>
</volist>
</volist>
回覆
這個 gettree 是什麼函式啊?
評論
生成分類樹的函式