Method for ThinkPHP to use smarty template engine

  • 2021-07-06 10:26:11
  • OfStack

ThinkPHP supports a variety of php template engines, which can be configured according to individual needs.
Let's take Smarty template engine as an example to tell you the specific operation process!

First, download an Smarty from Smarty official website. Download address of this site: https://www.ofstack.com/codes/16086. html.
Next, unzip the compressed package, and there will be two folders: demo and libs. Open the libs folder and copy everything.
Next, open the thinkphp folder under the root directory of your website. There is an vendor folder, this folder is TP call the third class library, just copy all the things paste over.
After that, open the configuration file of your project, which should be in the conf directory of your project directory, conf. php.

Add the following configuration:


'TMPL_ENGINE_TYPE'=>'Smarty'

If you want to configure more, you can also add


'TMPL_ENGINE_CONFIG'=>array( 
'caching'=>true, 
'template_dir'=>TMPL_PATH, 
'compile_dir'=>CACHE_PATH, 
'cache_dir'=>TEMP_PATH 
)

So you can use the Smarty template.

The file location of the template has not changed, nor has the cache location changed.


Related articles: