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, // 模板引擎普通标签开始标记 'tpl_begin' => '<{', // 模板引擎普通标签结束标记 'tpl_end' => '}>', // 标签库标签开始标记 'taglib_begin' => '{', // 标签库标签结束标记 'taglib_end' => '}', 'view_replace_str' => [ //字符替换部分 '/Upfiles/'=>'http://www.emmetltd.com/Uploads/', ], ];
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!