private function  categoryTree($parentid,$level)   //因为是本类中使用所以定于为私有函数{$Category= D('Category');$result = $Category->where("`parentid`=".$parentid)->order("listorder desc,catid desc")->select();if($result){$count=count($result);//当前子栏目个数$level++;//子栏目层级foreach($result as $v){$index++;    if($count==$index) $step="└─";else $step="├─";$step.=str_repeat('  ',$level-1);$nbsp=str_repeat('   ',$level-1);$nstr=$nbsp.$step;if($parentid==0) $nstr='';$v['step']=$nstr; $this->newData[$v['id']]=$v; //这一行是具体实际工作调试的成功效果,需要在类中建立属性  private $newData=array();                                                //目的就是将数据按查询的顺序存放到newData数组中//$newData[$v['catid']]=$v;   //如果直接用这个变量数据顺序不是希望的结果 if($v['child']==1)//如果有子栏目{$newData=$newData+$this->categoryTree($v['catid'],$level);}}}  //  return $newData;  }

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿
发表
评论
返回
顶部