Heim  >  Artikel  >  Backend-Entwicklung  >  ThinkPHP2.0调整使用Smarty模板

ThinkPHP2.0调整使用Smarty模板

WBOY
WBOYOriginal
2016-06-13 10:54:39798Durchsuche

ThinkPHP2.0整合使用Smarty模板

Smarty官网:http://www.smarty.net/download

如何操作的:

1. 首先去Smarty官网上下载一个Smarty,接下来解压压缩包,会有两个文件夹:demo和libs。打开libs文件夹,复制libs下所有内容(不包括libs)。

2. 打开你网站根目录下thinkphp的文件夹。里面有个vendor文件夹,这个文件夹是TP调用第三方类库用的

3. 在Vendor下新建一个Smarty的目录,然后把刚才复制的东西全部粘贴过来。

4. 打开 你项目的配置文件(项目根目录下/Conf/config.php),应该在你项目目录 的conf目录下conf.php这个文件。

加上如下配置:
'TMPL_ENGINE_TYPE'=>'Smarty'

如果 你想配置的更多,你还可以 加上
'TMPL_ENGINE_CONFIG'=>array(????
????'caching'=>true,????
????'template_dir'=>TMPL_PATH,????
????'compile_dir'=>CACHE_PATH,????
????'cache_dir'=>TEMP_PATH????
)

这样你就可以使用Smarty模板了。


补充一点:
我看有的教程是直接把libs目录下的所有文件复制到Vendor下,那么这样就需要进行如下操作:
ThinkPHP/Lib/Think/Util/Template/TemplateSmarty.class.php文件中需要把41行的?vendor('Smarty.Smarty#class');??改成 vendor('Smarty#class');??因为按照如上的目录是没有在Vendor目录下建Smarty目录的。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:PHPGACL使用权限控制Nächster Artikel:PHP学习札记(1)