$view= View::factory('hello');
$this->response->body($view->render());你这样试试
请教调用模板问题,谢谢
在application\classes\controller\下建立一个控制器hello.php,代码如下
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Hello extends Controller{
public function action_index(){
$this->request->response = View::factory('hello');
}
}
在application\views\下建立模板文件hello.php,代码如下
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>模板文件</title>
</head>
<body>
这里是模板文件
</body>
</html>
访问http://localhost/www/demo/index.php/hello/,却无法调用模板文件
请教各位是哪里的设置出了问题,谢谢
$view= View::factory('hello');
$this->response->body($view->render());你这样试试
这样可以,不过为什么$this->request->response = View::factory('hello'); 不行呢?
缺少render渲染.
2.4.x 和 3.0 模版呈现的方法变更了。注意切换
发表讨论