织梦的栏目管理非常帅,多级栏目显示上面非常清晰,今天大象仿了个织梦的多级栏目管理,废话不多说,上代码
1、递归类 typeunit.calss.php
class typeunit {
/**
* 读出所有分类,在类目管理页(list_type)中使用
*
* @access public
* @param int $table 表名
* @param int $topid 当前操作id
* @return string
*/
public function listtype($table='keshi',$topid=0){
$form = m($table);
$list = $form->where('topid='.$topid)->order(sort desc,id asc)->select();
foreach ($list as $k => $v) {
echo 'id '.$v['id'].' '.$v['name'].' 操作
';
$this->listtypeseed($table,$v['id']);
}
}
/**
* 读出子分类
*
* @access public
* @param int $table 表名
* @param int $topid 当前操作id
* @return string
*/
private function listtypeseed($table,$topid){
$form = m($table);
$list = $form->where('topid='.$topid)->order(sort desc,id asc)->select();
if($list){
echo '';
foreach ($list as $k => $v) {
echo 'id '.$v['id'].' '.$v['name'].' 操作
';
$this->listtypeseed(keshi,$v['id']);
}
echo '
';
}
}
}
?>2、模板页面 index.html
$tu = new typeunit();
$tu->listtype('keshi',0);
ad:真正免费,域名+虚机+企业邮箱=0元
