Yaf的视图使用起来很简单,默认情况下,控制器会自动加载对应的视图文件,其实也可以在bootstrap.php中进行全局控制,不让它自动加在模板,不过这里主要说一下视图文件的路径以及框架默认情况下的一些东西:
视图文件默认目录是在和Controllers平级的views下存放着,每个控制器的存放一个目录。
比如:在默认Index模块的情况下,他的控制器存放目录为application/controllers,那么他的视图文件就保存在application/views目录下;比如我在application/controllers下新建个User控制器,同时在User控制器中创建了一个test方法,那么test方法对应的视图文件就是:application/views/user/test.phtml。
如果在非默认模块下,比如Home模块(YAF模块的使用)下的视图文件的路径就为:application/modules/Home/views/
视图文件默认后缀是phtml,这个我们是可以修改的,方法也很简单。修改方法为:直接在conf/application.ini中的的相应配置段添加如下配置信息即可:
application.view.ext = 'html'
这样我们就把默认的视图文件的后缀改成了html了。
另外yaf的视图对象还有几个常用的方法:
assign:http://www.laruence.com/manual/yaf.class.view.simple.assign.html
render:http://www.laruence.com/manual/yaf.class.view.simple.render.html
display:http://www.laruence.com/manual/yaf.class.view.simple.display.html
setScriptPath:http://www.laruence.com/manual/yaf.class.view.simple.setScriptPath.html
getScriptPath:http://www.laruence.com/manual/yaf.class.view.simple.getScriptPath.html
作为一个yaf新手,其它的东西我暂时也没用到,也讲不出来,等等以后在使用中慢慢研究吧!