www.legu.cc/plugins/Demo/Controller/AdminIndexController.class.php
2021-09-06 11:50:33 +08:00

39 lines
1.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace plugins\Demo\Controller; //Demo插件英文名改成你的插件英文就行了
use Api\Controller\PluginController;//插件控制器基类
class AdminIndexController extends PluginController{
function _initialize(){
$adminid=sp_get_current_admin_id();//获取后台管理员id可判断是否登录
if(!empty($adminid)){
$this->assign("adminid",$adminid);
}else{
//TODO no login
}
}
function index(){
//$plugin_demo_model=D("plugins://Demo/PluginDemo");//实例化自定义模型PluginDemo ,需要创建plugin_demo表
//$plugin_demo_model->test();//调用自定义模型PluginDemo里的test方法
$users_model=D("Users");//实例化Common模块下的Users模型
//$users_model=D("Common/Users");//也可以这样实例化Common模块下的Users模型
$users=$users_model->limit(0,5)->select();
$this->assign("users",$users);
$this->display(":admin_index");
}
}