浏览模式: 标准 | 列表分类:PHP Framework
Submitted by gouki on 2009, January 8, 9:22 PM
从TP1.5开始,对于其他的模版引擎有了原生支持(不再是以前那种插件机制了)。
本文以使用smarty模版为例作点简单介绍,其他的,可以参考一下View.class.php中的fetch方法可知。
TP的SVN中已经含有smarty模版库,因此当你要使用的时候,只需要在项目的config.php里作一点简单的配置:
PHP代码
- 'TMPL_ENGINE_TYPE' => 'smarty',
从2009-01-07下午的SVN版本里,流年为又增加了一个TMPL_ENGINE_CONFIG这个数组,即:
PHP代码
- 'TMPL_ENGINE_CONFIG' = array(
- 'template_dir' => TMPL_PATH ,
- 'compile_dir' => CACHE_PATH . "tplCompile/",
- 'cache_dir' => CACHE_PATH . "tplCache/",
- 'left_delimiter' => '{',
- 'right_delimiter' => '}',
- 'caching' => false,
- 'force_compile' => true,
- 'compile_check' => true,
- ),
备注:如果按照我这样的写法,请到cache目录里手动创建tplCompile和tplCache两个目录,否则程序会报错。
报错信息大致为:
XML/HTML代码
- Catchable fatal error: Object of class Smarty could not be converted to string in D:\local\htdocs\ThinkPHP\Album\Temp\~runtime.php on line 145
如果出现这样的报错信息,请先检查这两个目录是否存在
在项目开发的时候,caching 最好设为false,否则你根本看不到效果。
如此设定完毕后,你就可以直接在项目中使用了,下面以Index模块的index方法进行举例:在IndexAction.class.php的index的方法里
PHP代码
- $this->assign("test" , "This is a test string");
- $this->display();
然后到模版里:
就可以看到输出了。不过,这里需要注意的是,如果你$this->display()没有指定文件名,那么默认的模版文件就是default/Index/index.html,这点和原先使用TP默认的模版引擎没有什么区别。
出现问题最大的应该是在include方法里,include的使用方法是:{include file="Public/header.html"},就象我前面所说,smarty的模版路径只指到了tpl目录,但实际上,我们是在默认的default目录下操作,因此正确的写法应该是{include file="default/Public/header.html"}
如果我们写的程序要对应多模版,那么,上面那种直接写死default的方法是不行的,还好,TP为我们留了一个常量:TEMPLATE_NAME,于是我们的写法就可以是现在这样:
XML/HTML代码
- {include file="`$smarty.const.TEMPLATE_NAME`/Public/header.html"}
现在试一下,是否公用目录里的header.html被加载了?
最后再报一个warning。如果是在WINDOWS下面开发并且开启了DEBUG_MODE,那么你在读取模版的时候,页面的Trace信息里,偶尔会出现一个注意:
XML/HTML代码
- [ 09-01-08 14:36:02 ] 注意:[2] unlink(./Cache/tplCompile/\%%70^706^706C3AFE%%index.html.php) [function.unlink]: No such file or directory core.write_file.php 第 44 行.
这些信息,可以被忽略掉。模版文件还是会正常的生成和编译的。它只会在第一次生成模版编译文件的时候出现
Tags: thinkphp, smarty, template
PHP Framework | 评论:0
| 阅读:28366
Submitted by gouki on 2009, January 2, 12:47 AM
QEEPHP终于发布了,没有看到廖羽雷吃笔记本,也是一种遗憾。
要知道QeePHP可是让人等了整整一年,当年论坛上就有人说:宁可相信世上有鬼也不相信老廖的嘴。可见让人有多失望
不过,在昨天凌晨的时候,QeePHP还是提供了下载,不过下载完了之后还没有时间仔细观摩。
初步看了一下,目录结构与ZF相类似,自动加载类库也使用了spl_auto_load,因为使用了这个函数,造成的后果是,文件名全部是小写了。呵呵(不知道原因的可以去查看这个函数)
其他还没有仔细看。
可以先看官方:http://qeephp.com
Tags: php, framework, qeephp, fleaphp, 廖羽雷
PHP Framework | 评论:5
| 阅读:35588
Submitted by gouki on 2009, January 2, 12:43 AM
YY博鼎力之作哦,大家支持一下。
除此之外,他还写了一个yBlog,同样请大家支持
http://www.yhustc.com,就是yBlog的官方网站。
介绍:
ThinkPHP 2008年离线资料包,将ThinkPHP论坛使用版面与帮助资料版面2008年所有帖子全部采集生成HTML文件,并添加了全文检索功能。可以在不联网的情况下方便查找论坛中相关问题的讨论,并且可以方便的搜索,比CHM的搜索更强大的搜索。点击搜索结果可以直接来到帖子页,也可以直接通过首页进入相关版面列表,就跟操作BBS一样。
注意:需要安装.NET框架2.0及以上版本
图片:



下载地址:http://www.yhustc.com/ThinkPHP2008.rar
本站分流:下载
Tags: thinkphp, 资料, yhustc
PHP Framework | 评论:0
| 阅读:24101
Submitted by gouki on 2008, September 15, 11:38 PM
Submitted by gouki on 2008, August 20, 11:53 PM
1.6版本的zf终于将SOAP放进来了,同时也增加了DOJO的支持。不过我没有想通。为什么那么多的JS框架,最终会选择了DOJO。
这些不是我能够想得通的。还是看看到底更新了什么再说吧。
An overview of new features:
- Dojo Integration
- JSON-RPC
- Dojo Data packing
- Dojo View Helper
- Dijit integration with Zend_Form & Zend_View
- Dojo Library Distribution
- SOAP
- SOAP Server
- SOAP Client
- Autodiscovery
- WSDL access
- WSDL Generation
- Preview of Tooling Project in Laboratory (see /laboratory folder)
- Command Line Interface
- Project Asset Management
- Unit Testing Harness for Controllers
- Lucene 2.3 Index File Format Support
- Zend_Session save handler for Database Tables
- Paginator Component
- Text/Figlet Support
- ReCaptcha Service
- Zend_Config_Xml Attribute Support
- Character Set Option for DB Adapters
- Zend File Transfer Component
- New Media View Helpers (Flash, Quicktime, Object, and Page)
- Support in Zend_Translate for INI File Format
This obviously marks a very important step towards a high-quality, highly tested 1.6 GA release. Thanks to everyone who has contributed to this release in any way: with patches/check ins, documentation/translations, and bug reports.
But our work is not yet over! Let's do our best to bring this release to the breaking point to find areas we can improve the release for General Availability. Based on your feedback we will determine in the next few weeks whether we require additional release candidates, so please provide feedback on our issue tracker (http://framework.zend.com/issues) as soon as you can and ask any questions/post your experiences on the appropriate mailing list.
Again, the Zend Framework community does NOT recommend this release for production use. We do, however, recommend evaluating new features in this release with existing and new applications.
Enjoy 1.6RC1, and see you on the issue tracker, wiki, and mailing lists!
————END————
不知道:Zend File Transfer Component,这个会给我们带来什么样的惊喜?大文件传输还是其他的?下载源码研究一下,哈哈
Tags: soap, zend framework, zf, framework, dojo
PHP Framework | 评论:0
| 阅读:26856