Home > PHP Framework > ThinkPHP > body text

thinkphp5.1 uses Smarty template engine

L
Release: 2020-05-29 10:17:12
forward
3600 people have browsed it


thinkphp5.1 uses Smarty template engine


Thinkphp5.1 uses Smarty template engine

Friends who are used to using smarty , if you don’t want to modify the existing template code, you can directly use composer to install the Smarty library, and modify the template configuration file to use the smarty template directly
think-smarty
ThinkPHP5.1Smarty engine driver

Installation Method
Use composer to install the template engine method: composer require emmetltd/think-smarty

ThinkPHP5.1 Configure the parameters in the template.php file

return [
// 模板引擎类型 支持 php think 支持扩展
'type' => 'Smarty',
// 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
'auto_rule' => 1,
// 模板路径
'view_path' => '',
// 模板后缀
'view_suffix' => 'html',
// 模板文件名分隔符
'view_depr' => '_', //DIRECTORY_SEPARATOR,
// 模板引擎普通标签开始标记
&#39;tpl_begin&#39; => &#39;<{&#39;,
// 模板引擎普通标签结束标记
&#39;tpl_end&#39; => &#39;}>&#39;,
// 标签库标签开始标记
&#39;taglib_begin&#39; => &#39;{&#39;,
// 标签库标签结束标记
&#39;taglib_end&#39; => &#39;}&#39;,
&#39;view_replace_str&#39; => [ //字符替换部分
&#39;/Upfiles/&#39;=>&#39;http://www.emmetltd.com/Uploads/&#39;,
],
];
Copy after login

Then the template index/view/index_index.html will be loaded when return view(); in the controller index/index::index

Recommended tutorial: "TP5

The above is the detailed content of thinkphp5.1 uses Smarty template engine. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:thinkphp
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template