function index(){
$cate=D('cate');
$list=$cate->field("id,catid,name,show,directory,sorting,pid,path,concat(path,'-',id) as bpath")->order('bpath')->select();
/*foreach($list as $key=>$value){
$list[$key]['count']=count(explode('-',$value['bpath']));
}*/
foreach($list as $key=>$value){
$list[$key]['count']=count(explode('-',$value['bpath']));
if ($value['pid'] == 0){
$list[$key]['name'] = $list[$key]['name'];
}else{
$list[$key]['name'] = $this->getStr($list[$key]['count']).' -'.$list[$key]['name'];
}
}
$this->assign('alist',$list);
$this->display();
}
private function getStr($p){
$str = "";
for($i=1;$i<$p;$i++){
$str.=" ";
}
return $str;
}
function add(){
$cate=new NavigationModel('cate');
if($vo=$cate->create()){
if($cate->add()){
$this->success('添加成功');
}else{
$this->error('添加栏目失败');
}
}else{
$this->error($cate->getError());
}
}怎么添加内容 我就不会谢了最佳答案