NoteDeep
对于默认模块, 视图文件的路径是在application目录下的views目录中以小写的action名的目录中
如:IndexController的indexAction 对应视图: application/views/index/index.phtml
<html> <head> <title>Hello World</title> </head> <body> <?php echo $content;?> </body> </html>

在bootstrap.php中,关闭默认的视图自动渲染
// 方式一:
Yaf_Dispatcher::getInstance()->autoRender(false);

// 方式二:
$dispatcher->getInstance()->disableView();

在application.ini中配置模板文件的后缀名,默认为 phtml
application.view.ext = "html"

Controller中把变量assign给模板
$this->getView()->assign('user','lvtao'); //模板文件中直接用php语法输出

Controller中输出渲染结果
// 方式一:render方法,需要加echo
echo $this->getView()->render('User/index.phtml');

// 方式二: display方法
$this->getView()->display('User/index.phtml');





评论列表