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.
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
namespace Media\Widget;
|
|
use Think\Controller;
|
|
|
|
/**
|
|
* 分类widget
|
|
* 用于动态调用分类信息
|
|
*/
|
|
|
|
class CategoryWidget extends Controller{
|
|
|
|
/* 显示指定分类的同级分类或子分类列表 */
|
|
public function lists($cate, $child = false){
|
|
|
|
$field = 'id,name,pid,title,link_id';
|
|
if($child){
|
|
$category = D('Category')->getTree($cate, $field);
|
|
$category = $category['_'];
|
|
} else {
|
|
$category = D('Category')->getSameLevel($cate, $field);
|
|
}
|
|
$this->assign('category', $category);
|
|
$this->assign('current', $cate);
|
|
$this->display('Category/lists');
|
|
}
|
|
|
|
/* 显示指定分类的同级分类或子分类列表 */
|
|
public function new_lists($cate, $child = false){
|
|
|
|
$field = 'id,name,pid,title,link_id';
|
|
if($child){
|
|
$category = D('Category')->getTree($cate, $field);
|
|
$category = $category['_'];
|
|
} else {
|
|
$category = D('Category')->getSameLevel($cate, $field);
|
|
}
|
|
$this->assign('category', $category);
|
|
$this->assign('current', $cate);
|
|
$this->display('Category/new_lists');
|
|
}
|
|
|
|
}
|