- 53浏览
- 2022-10-21
输出:
学生模块
——学生管理
——添加学生
栏目模板
——管理栏目
用户模块
——用户管理
——————用户管理
——————添加用户
——分组管理
图标模块
——图标模块
系统设置
——学校模块
——————学校管理
——————增加学校
——后台首页
——合作单位
——————合作单位管理
——————增加合作单位
——上报教学站点
——————站点管理
——————添加站点
模板代码:
{volist name="name" id="vo"}
<div>
<span>{$vo.title}</span>
</div>
{volist name="vo.child" id="vo2"}
<div>
<span>——{$vo2.title}</span>
{volist name="vo2.child" id="vo3"}
<div>
<span>——————{$vo3.title}</span>
</div>
{/volist}
</div>
{/volist}
{/volist}
tp5 控制器PHP代码:
1、以静态数组的办法
$data=[
["id"=>22,
"user" => "houn",
"pid"=>0,
"child"=>[
[
"id"=>22,
"user" => "baichi",
"pid"=>0,
"child"=>[
[
"id"=>22,
"user" => "baichi03",
"pid"=>0,
],
[
"id"=>22,
"user" => "baichi03",
"pid"=>0,
],
]
],
[
"id"=>22,
"user" => "baichi",
"pid"=>0,
],
]
],
["id"=>22,
"user" => "houn",
"pid"=>0,
"child"=>""
],
["id"=>22,
"user" => "houn",
"pid"=>0,
"child"=>[
[
"id"=>22,
"user" => "12baichi",
"pid"=>0,
"child"=>[
[
"id"=>22,
"user" => "21baichi03",
"pid"=>0,
],
[
"id"=>22,
"user" => "21baichi03",
"pid"=>0,
],
]
],
[
"id"=>22,
"user" => "baichi",
"pid"=>0,
],
]
],
];
$this->assign('name',$data);
2、读取数据库形式 TP5 php代码
//循环列出栏目数据 1级
$res = Db::name('menu')->where('flid',1)->order('uid desc')->select();
$data="";
foreach($res as $k => $v){
//2级
$res2 = Db::name('menu')->where("pid",$v['id'])->select();
$data2="";
foreach($res2 as $k2 => $v2){
//3级
$res3 = Db::name('menu')->where("pid",$v2['id'])->select();
$data3="";
foreach($res3 as $k3 => $v3){
$data3[$k3]['id']=$v3['id'];
$data3[$k3]['title']=$v3['title'];
$data3[$k3]['child']=$v3['title'];
}
$data2[$k2]['id']=$v2['id'];
$data2[$k2]['title']=$v2['title'];
$data2[$k2]['child']=$data3;
}
$data[$k]['id']=$v['id'];
$data[$k]['title']=$v['title'];
$data[$k]['child']=$data2;
}
$this->assign('name',$data);
进阶例子:
$where = new Where;
if($state){
$where['state'] = $state-1;
}
if($search){
$where['number'] = ['like', "%".$search."%"];
}
$where['deleted'] = 0;
$where['user_id'] = $Session['user_id'];
$list = Db::name('order')
->field('id,number,price,type,state,time,pay_time')
->where($where)
->order(['id' => 'desc'])
->paginate(10,false,['query' => request()->param(),'type' => 'page\Page','var_page' => 'page']);
if(!empty($list)){
foreach($list as $k => $v){
$oprs = Db::name('order_product')->field('id,title,num,price,pid,controller,img')->where('number',$v['number'])->select();
if(!empty($oprs)){
foreach($oprs as $k2 => $v2){
if($v2['controller']=='Combination'){//组合
$p_list= Db::name('order_product_clist')->field('id,title,controller,price,img,type_mold,num,pid')->where('opid',$v2['id'])->select();
if(!empty($p_list)){
$cbrs=[];
foreach($p_list as $k3=> $v3){
// //$price31 +=$v3['price'];
$cbrs[$k3]['id']=$v3['pid'];
$cbrs[$k3]['title']=$v3['title'];
// //$cbrs['price']=$v3['price'];
$cbrs[$k3]['img']=$v3['img']?\app\admin\model\Common::file_url($v3['img']):$this->system_config['system_index_no_img'];
if($v3['controller']=='Live'){
$ttt="直播";
}elseif($v3['controller']=='Video'){
$ttt="点播";
}elseif($v3['controller']=='Testpaper'){
$ttt="试卷";
}elseif($v3['controller']=='Shop'){
$ttt="商城";
}else{
$ttt="其它";
}
$cbrs[$k3]['controller']=$v3['controller'];
$cbrs[$k3]['type_title']=$ttt;
}
}else{
$cbrs=[];
}
}
if($v2['controller']=='Testpaper'){//试卷 试卷ID要加密
//$v2['id'] = 21;
$v2['pid'] = model('index/CommonModel')->lock_url($v2['id'],'id');
}else{
$v2['pid'] =$v2['pid'];
}
if($v2['controller']=='Live'){
$type_title1='直播';
}elseif($v2['controller']=='Video'){
$type_title1='点播';
}elseif($v2['controller']=='Testpaper'){
$type_title1='试卷';
}elseif($v2['controller']=='Shop'){
$type_title1='商品';
}elseif($v2['controller']=='Combination'){
$type_title1='组合';
}else{
$type_title1='商品';
}
$v2['type_title']=$type_title1;
$v2['img'] =$v2['img']?\app\admin\model\Common::file_url($v2['img']):$this->system_config['system_index_no_img'];
$v2['child'] =$cbrs;
$oprs[$k2] = $v2;
}
}else{
$oprs=[];
}
$v['child'] =$oprs;
$list[$k] = $v;
}
}
版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、本文由会员转载自互联网,如果您是文章原创作者,请联系本站注明您的版权信息。