You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
649 B
PHP
38 lines
649 B
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
use think\Controller;
|
|
use think\Db;
|
|
class Topmenu extends Common
|
|
{
|
|
function getTree($data,$ppd)
|
|
{
|
|
$html = '';
|
|
$ppid=-1;
|
|
foreach($data as $k =>$v)
|
|
{
|
|
if($v['pid'] == $ppd)
|
|
{
|
|
$html .= "<li ><a href='".$v['linkurl']."' >".$v['pidname']."</a>";
|
|
$ppid=$v['ppid'];
|
|
$html .= $this->getTree($data,$v['id']);
|
|
$html = $html ."</li>";
|
|
}
|
|
}
|
|
if($ppd==0) {
|
|
return $html ?'<ul class="nav">'.$html .'</ul>': $html;
|
|
}
|
|
else
|
|
{
|
|
return $html ?'<ul >'.$html .'</ul>': $html;
|
|
}
|
|
}
|
|
function index()
|
|
{
|
|
$data=Db::query("select * from sys_menu ");
|
|
$menu= $this->getTree($data,0);
|
|
$this->assign('data',$menu);
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
?>
|