标签:get 重要 mon dedecms require 程序 显示 xtend 获取
网站根目录/
|-自定义模块
|-control 控制器
|-model 模型
|-static 静态文件
|-images
|-js
|-css
|-templates 模块目录
|-default
//引入重要的文件 require_once(dirname(__file__)).‘/../include/common.inc.php‘; require_once(DEDEINC.‘/request.class.php‘); //指定了如何请求一个控制器的某个方法 //http://网站/自定义模块/index.php?c=控制器&a=方法 $ct = Request(‘c‘, ‘index‘); $ac = Request(‘a‘, ‘index‘); //统一应用程序入口 RunApp($ct, $ac);
class test extend Control {
//方法前面需加上ac_
public function ac_test() {
echo ‘测试‘;
}
public function ac_getList() {
//通过request()来获取参数
$id = request(‘id‘);
//获取模型数据
$data = $this->Model(‘elist‘)->getList();
//分配数据
$GLOBALS[‘data‘] = $data;
//设置模板
$this->SetTemplate(‘showlist.htm‘);
//显示模板
$this->Display();
}
}
class elist extend Model {
public function getList() {
$sql = ‘select * from dede_test‘;
$this->dsql->SetQuery($sql);
$this->dsql->Execute();
$rows = array();
while($row = $this->dsql->GetArray()) {
$rows[] = $row;
}
return $rows;
}
}
<?php foreach($data as $k => $v): ?> <?php endforeach; ?>
标签:get 重要 mon dedecms require 程序 显示 xtend 获取
原文地址:http://www.cnblogs.com/jkko123/p/6351699.html